RosettaCodeData/Task/Remove-duplicate-elements/CafeOBJ/remove-duplicate-elements-2...

20 lines
533 B
Plaintext

mod! NO-DUP-LIST(ELEMENTS :: TRIV) {
op __ : Elt Elt -> Elt { comm assoc idem assoc }
}
-- Runs on Version 1.5.1(PigNose0.99) of CafeOBJ
-- The tests are performed after opening instantiated NO-DUP-LIST with various concrete types.
-- Test on lists of INT
open NO-DUP-LIST(INT) .
red 2 1 2 1 2 1 3 .
-- Gives (2 1 3):Int
open NO-DUP-LIST(INT) .
reduce 1 1 2 1 1 .
close
open NO-DUP-LIST(CHARACTER) .
reduce 'a' 'b' 'a' 'a' .
close
open NO-DUP-LIST(STRING) .
reduce "abc" "def" "abc" "abc" "abc" .
close