Advertisement
Keodedad

Untitled

Apr 9th, 2019
1,053
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.30 KB | None | 0 0
  1. let rec map_filter =
  2.   fun f l ->
  3.   match l with
  4.     [] -> []
  5.   | h::t ->
  6.     try (f h)::map_filter f t
  7.     with _ -> map_filter f t
  8.  
  9. exception NoResult
  10.  
  11. let rec f = fun n l ->
  12.   match l with
  13.     [] -> if n = 0 then [] else raise NoResult
  14.   | h::t ->
  15.     try h::(f (n - h) t)
  16.     with _ -> f n t
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement