Skip to content

Commit f7f72f9

Browse files
committed
- added a multiplication function for a list of optional integers.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4748 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 9f3acb3 commit f7f72f9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

Compiler/Util.mo

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5532,5 +5532,27 @@ algorithm
55325532
end matchcontinue;
55335533
end listAppendNoCopy;
55345534

5535+
public function mulListIntegerOpt
5536+
input list<Option<Integer>> ad;
5537+
input Integer acc "accumulator, should be given 1";
5538+
output Integer i;
5539+
algorithm
5540+
i := matchcontinue(ad, acc)
5541+
local
5542+
Integer ii, iii;
5543+
list<Option<Integer>> rest;
5544+
case ({}, acc) then acc;
5545+
case (SOME(ii)::rest, acc)
5546+
equation
5547+
acc = ii * acc;
5548+
iii = mulListIntegerOpt(rest, acc);
5549+
then iii;
5550+
case (NONE()::rest, acc)
5551+
equation
5552+
iii = mulListIntegerOpt(rest, acc);
5553+
then iii;
5554+
end matchcontinue;
5555+
end mulListIntegerOpt;
5556+
55355557
end Util;
55365558

0 commit comments

Comments
 (0)