(* file: sublists.ml * author: Bob Muller * * CS1101 Computer Science I * * The sublist example. Illustrates: * 1. recursion - solving the problem by patching up a solution to a * smaller instance of the problem. * 2. map * 3. anonymous functions * * sublists : 'a list -> ('a list) list *) let rec sublists xs = match xs with | [] -> [[]] | x :: xs -> let ans = sublists xs in let newPart = List.map (fun ys -> x :: ys) ans in ans @ newPart