Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let memoize f =
- let table = Hashtbl.Poly.create () in
- fun x ->
- match Hashtbl.find table x with
- | Some y -> y
- | None ->
- let y = f x in
- Hashtbl.add_exn table ~key:x ~data:y;
- y
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement