Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let rec fold (combine: 'a -> 'b -> 'b) (base: 'b) (l: 'a list) : 'b =
- begin match l with
- | [] -> base
- | x :: xs -> combine x (fold combine base xs)
- end
- let test () : bool =
- not (for_all (fun x -> x > 0) [1; 2; -5; -33; 2])
- ;; run_test "for_all: multiple elements; returns false" test
- let for_all (pred: 'a -> bool) (l: 'a list) : bool =
- fold (fun(x:'a)(acc: bool)-> _?_&&_?_ )false l
Add Comment
Please, Sign In to add comment