return subscript(environment, subscripts, 0);\r
}\r
\r
+ public void applyPartial(Array[] indices, Array value, int pos) {\r
+ Array arr = indices[pos];\r
+ if(Array.FULL == arr) {\r
+ for(int i=0;i<elements.size();i++) {\r
+ if(pos < (indices.length-1)) {\r
+ ((Array)elements.get(i)).applyPartial(indices, (Array)value.element(i), pos+1);\r
+ } else {\r
+ elements.set(i, value.element(i));\r
+ }\r
+ }\r
+ } else if(arr.dimension() == 1) {\r
+ int index = ((Double)arr.element(0)).intValue();\r
+ if(pos < (indices.length-1)) {\r
+ ((Array)elements.get(index)).applyPartial(indices, value, pos+1);\r
+ } else {\r
+ elements.set(index, (Array)value.element(index));\r
+ }\r
+ } else {\r
+ for(Object element : arr.elements) {\r
+ int i = ((Double)element).intValue();\r
+ if(pos < (indices.length-1)) {\r
+ ((Array)elements.get(i)).applyPartial(indices, (Array)value.element(i), pos+1);\r
+ } else {\r
+ elements.set(i, value.element(i));\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ public void applyPartial(Array[] indices, Array value) {\r
+ applyPartial(indices, value, 0);\r
+ }\r
+\r
}\r
\r
if(value instanceof Array) {\r
if(base.isStoredAsArray(env)) {\r
- env.put(base.index(env, subscripts), value);\r
+ if(SolverUtils.isFullSubscript(subscripts)) {\r
+ env.put(base.index(env, subscripts), value);\r
+ } else {\r
+ Array[] indices = SolverUtils.parseSubscripts(env, subscripts);\r
+ Array current = (Array)env.getValue(base.index);\r
+ current.applyPartial(indices, (Array)value);\r
+ env.put(base.index, current);\r
+ }\r
} else {\r
assignArray(env, base.index(env, subscripts), (Array)value, 0);\r
}\r
\r
if(isStoredAsArray(environment)) {\r
\r
- Array array = (Array)environment.getValue(index);\r
- if(subscripts != null) {\r
- return array.subscript(environment, subscripts);\r
+ Object value = environment.getValue(index);\r
+ if(value instanceof Array) {\r
+ Array array = (Array)value;\r
+ if(subscripts != null) {\r
+ return array.subscript(environment, subscripts);\r
+ }\r
}\r
- else return array;\r
+ return value;\r
\r
} else {\r
\r