Guest User

Untitled

a guest
Sep 25th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. let rec fold (combine: 'a -> 'b -> 'b) (base: 'b) (l: 'a list) : 'b =
  2. begin match l with
  3. | [] -> base
  4. | x :: xs -> combine x (fold combine base xs)
  5. end
  6.  
  7. let test () : bool =
  8. not (for_all (fun x -> x > 0) [1; 2; -5; -33; 2])
  9. ;; run_test "for_all: multiple elements; returns false" test
  10.  
  11. let for_all (pred: 'a -> bool) (l: 'a list) : bool =
  12. fold (fun(x:'a)(acc: bool)-> _?_&&_?_ )false l
Add Comment
Please, Sign In to add comment