(* FILTER (P,L) -- P is a predicate (i.e. a function that returns true or false) L is a list FILTER (P,L) returns the elements in L for which P is true e.g. Given: fun P X = ((X mod 2) = 0); FILTER (P,L) would return the even numbers in L e.g. FILTER (P,[1,2,3,4,5]) = [2,4] *) fun FILTER (P,[]) = [] | FILTER (P,head::tail) = if (P head) then head::(FILTER (P,tail)) else (FILTER (P,tail)) ; use "FIRST_ARG"; local fun P X = ((X mod 2) = 0) in val evens = FIRST_ARG (FILTER,P) end;