less(k, lst) to return a list consisting of all
integers in lst that are less than
k.fn : int * int list -> int list
adjacent(lst) to determine whether there are two
adjacent occurences of an element in list lst.fn : ''a list -> bool
cycle(lst, i) cycle lst i
times. E.g. cycle([1, 2, 3, 4, 5], 3) => [4,
5, 1, 2, 3].fn : 'a list * int -> 'a list
duplicate(lst) given the list [a1, a2, ..., an]
produce the list [a1, a1, a2, a2, ..., an, an].fn : 'a list -> 'a list
basic.sml
fun reduce (f,v,nil) = v
| reduce (f,v,a::y) = f(a,reduce(f,v,y));
fun length lst = reduce(______,_______,_______);
fun append (lst1,lst2) = reduce(_______,_____,_______);
(* append lst1 and lst2 *)
fun remove_if (f,lst) = reduce(_____,_____,_______);
(* e.g. remove_if(fn(x) => x = 1, [1,2,1,3,1,4,1,5]) =
[2,3,4,5] *)
fun map (f,lst) = reduce(_____,_____,_______);
(* the map function *)
fun suffixes(lst) = reduce(_____,_____,_______);
(* e.g. suffixes([1,2,3]) = [[1,2,3], [2,3], [3], []]; *)
Filename: higher.sml