Skip to content

Commit

Permalink
- added a multiplication function for a list of optional integers.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4748 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Jan 7, 2010
1 parent 9f3acb3 commit f7f72f9
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Compiler/Util.mo
Expand Up @@ -5532,5 +5532,27 @@ algorithm
end matchcontinue;
end listAppendNoCopy;

public function mulListIntegerOpt
input list<Option<Integer>> ad;
input Integer acc "accumulator, should be given 1";
output Integer i;
algorithm
i := matchcontinue(ad, acc)
local
Integer ii, iii;
list<Option<Integer>> rest;
case ({}, acc) then acc;
case (SOME(ii)::rest, acc)
equation
acc = ii * acc;
iii = mulListIntegerOpt(rest, acc);
then iii;
case (NONE()::rest, acc)
equation
iii = mulListIntegerOpt(rest, acc);
then iii;
end matchcontinue;
end mulListIntegerOpt;

end Util;

0 comments on commit f7f72f9

Please sign in to comment.