1 | function 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;
|
---|
12 | algorithm
|
---|
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;
|
---|
24 | end isEqualOnTrue;
|
---|
25 |
|
---|
26 | function main
|
---|
27 | algorithm
|
---|
28 | _ := isEqualOnTrue({"a"}, {"b"}, stringEq);
|
---|
29 | end main;
|
---|