(* To compile this file, run: * * ocamlbuild -use-ocamlfind -pkg compsci631 -pkg ppx_test fp.d.byte * * This produces an executable called ./fp.d.byte, which runs all the * test cases in the file. * * If you've renamed the file to say foo.ml, you can instead run: * * ocamlbuild -use-ocamlfind -pkg compsci631 -pkg ppx_test foo.d.byte *) (* This is necessary for let%TEST to work. *) module PTest = Ppx_test.Test (* Do not change this definition *) let rec foldr (f : 'a -> 'b -> 'b) (acc: 'b) (lst : 'a list) : 'b = match lst with | [] -> acc | hd :: tl -> f hd (foldr f acc tl) (* Do not change this definition *) let rec unfold (p : 'b -> bool) (g : 'b -> 'a * 'b) (acc : 'b) : 'a list = match p acc with | true -> [] | false -> let (a, acc') = g acc in a :: (unfold p g acc') let length (lst : 'a list) : int = failwith "not implemented" let filter (pred : 'a -> bool) (lst : 'a list) : 'a list = failwith "not implemented" let build_list (f : int -> 'a) (len : int) : 'a list = failwith "not implemented" let is_empty (lst : 'a list) : bool = failwith "not implemented" let zip (lst1 : 'a list) (lst2 : 'b list) : ('a * 'b) list = failwith "not implemented" let map_using_unfold (f : 'a -> 'b) (lst : 'a list) : 'b list = failwith "not implemented" let map_using_fold (f : 'a -> 'b) (lst : 'a list) : 'b list = failwith "not implemented" let factorial n = failwith "not implemented" let insert (x : int) (lst : int list) : int list = failwith "not implemented" let insertion_sort (xs : int list) = failwith "not implemented" type 'a tree = | Leaf | Node of 'a tree * 'a * 'a tree let rec same_in_order (t: 'a tree): 'a list = failwith "not implemented" let rec from_to (m : int) (n: int) : int list = failwith "not implemented" let%TEST "unsurprisingly, addition works correctly" = 1 + 2 = 3 (* Runs all tests declared with let%TEST. This must be the last line in the file. *) let _ = Ppx_test.Test.collect ()