tasks a-s

This commit is contained in:
Ingy döt Net 2013-04-10 23:57:08 -07:00
parent 47bf37c096
commit b83f433714
12433 changed files with 156208 additions and 123 deletions

View file

@ -0,0 +1,17 @@
module PowerSet(S: Set.S) =
struct
include Set.Make (S)
let map f s =
let work x r = add (f x) r in
fold work s empty
;;
let powerset s =
let base = singleton (S.empty) in
let work x r = union r (map (S.add x) r) in
S.fold work s base
;;
end;; (* PowerSet *)

View file

@ -0,0 +1 @@
let subsets xs = List.fold_right (fun x rest -> rest @ List.map (fun ys -> x::ys) rest) xs [[]]