Remove duplicate elements: Difference between revisions
→{{header|CafeOBJ}}
Line 959:
=={{header|CafeOBJ}}==
The parametrized module NO-DUP-LIST(ELEMENTS :: TRIV) defines the signature of a space separated list structure. The removal of duplicates is handled by the equational properties listed after the signature in brackets {}. There is no user written code in module NO-DUP-LIST. The binary operation (_ _) is associative, commutative, and idempotent, meaning (x , x) = x. This list structure does not permit duplicates, they are removed during evaluation (called reduction in CafeOBJ). Using this module we can perform set union, just by evaluating two lists e.g:
--> (4 5 1 2 3):Int
</lang>
Line 1,001 ⟶ 999:
Idempotency is applied at rightmost inner brackets:
We get rewrite ''(1 1) -> 1''
<lang> (1 ((1 2) 1)) </lang>
|