RosettaCodeData/Task/Remove-duplicate-elements/MLite/remove-duplicate-elements.m...

16 lines
414 B
Plaintext

fun mem (x, []) = false
| (x eql a, a :: as) = true
| (x, _ :: as) = mem (x, as)
;
fun remdup
([], uniq) = rev uniq
| (h :: t, uniq) = if mem(h, uniq) then
remdup (t, uniq)
else
remdup (t, h :: uniq)
| L = remdup (L, [])
;
println ` implode ` remdup ` explode "the quick brown fox jumped over the lazy dog";
println ` remdup [1,2,3,4,4,3,2,1, "dog","cat","dog", 1.1, 2.2, 3.3, 1.1];