\r
import java.util.Map;\r
\r
+import fi.semantum.sysdyn.solver.Array.Modifier;\r
+\r
public class Negation implements IExpression {\r
\r
public IExpression exp;\r
\r
@Override\r
public Object evaluate(IEnvironment environment) {\r
- Double d = (Double)exp.evaluate(environment);\r
- if(d == null) return null;\r
- return -d;\r
+ Object value = exp.evaluate(environment);\r
+ if(value == null) return null;\r
+ if(value instanceof Double) {\r
+ return -((Double)value); \r
+ } else if(value instanceof Array) {\r
+ return ((Array)value).copy(new Modifier() {\r
+\r
+ @Override\r
+ public Object modify(Object o) {\r
+ if(o instanceof Double) {\r
+ return -((Double)o); \r
+ } else {\r
+ throw new IllegalStateException();\r
+ }\r
+ }\r
+ \r
+ });\r
+ } else {\r
+ throw new IllegalStateException();\r
+ }\r
}\r
\r
@Override\r