(*world*) signature WORLD = sig val remove: ''a -> ''a list -> ''a list val reverse: 'a list -> 'a list end; structure world:WORLD = struct fun accumulate f a [] = a |accumulate f a (b::x) = accumulate f (f a b) x; fun append x y = x @ y; fun member e [] = false |member e (a::x) = e=a orelse member e x; fun remove e [] = [] |remove e (a::x) = if e=a then remove e x else a::remove e x; fun subset x y = let fun subsetp [] y = true |subsetp (a::x) y = member a y andalso subsetp x y in (length x) <= (length y) andalso subsetp x y end; fun superset x y = subset y x; fun filter p [] = [] |filter p (a::x) = if p a then a::filter p x else filter p x; fun exists p [] = false |exists p (a::x) = p a orelse exists p x; fun all p [] = true |all p (a::x) = p a andalso all p x; fun zip f [] [] = [] |zip f [] (b::y) = [] |zip f (a::x) [] = [] |zip f (a::x) (b::y) = f a b::zip f x y; fun nth n [] = [] |nth 1 (a::x) = [a] |nth n (a::x) = nth (n-1) x; fun reverse [] = [] |reverse (a::x) = (reverse x) @ [a]; end;