Ticket #2810: bug2810.mo

File bug2810.mo, 706 bytes (added by Per Östlund, 10 years ago)
Line 
1function isEqualOnTrue<ElementType>
2 input list<ElementType> inList1;
3 input list<ElementType> inList2;
4 input CompFunc inCompFunc;
5 output Boolean outIsEqual;
6
7 partial function CompFunc
8 input ElementType inElement1;
9 input ElementType inElement2;
10 output Boolean outIsEqual;
11 end CompFunc;
12algorithm
13 outIsEqual := match(inList1, inList2)
14 local
15 ElementType e1, e2;
16 list<ElementType> rest1, rest2;
17
18 case (e1 :: rest1, e2 :: rest2) guard(inCompFunc(e1, e2))
19 then isEqualOnTrue(rest1, rest2, inCompFunc);
20
21 case ({}, {}) then true;
22 else false;
23 end match;
24end isEqualOnTrue;
25
26function main
27algorithm
28 _ := isEqualOnTrue({"a"}, {"b"}, stringEq);
29end main;