Skip to content

Commit

Permalink
- Fix Array.map.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@23151 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Nov 3, 2014
1 parent 4587515 commit 51f6898
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Compiler/Util/Array.mo
Expand Up @@ -130,13 +130,16 @@ public function map<TI, TO>
end FuncType;
protected
Integer len := arrayLength(inArray);
TO res;
algorithm
// If the array is empty, use list transformations to fix the types!
if len == 0 then
outArray := listArray({});
else
// If the array isn't empty, use the first element to create the new array.
outArray := arrayCreateNoInit(len, inFunc(arrayGetNoBoundsChecking(inArray, 1)));
res := inFunc(arrayGetNoBoundsChecking(inArray, 1));
outArray := arrayCreateNoInit(len, res);
arrayUpdate(outArray, 1, res);

for i in 2:len loop
arrayUpdate(outArray, i, inFunc(arrayGetNoBoundsChecking(inArray, i)));
Expand Down

0 comments on commit 51f6898

Please sign in to comment.