Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let memoize (f : 'a -> 'b) =
- let cache = new Dictionary<'a, 'b>()
- let memoizedF x =
- match cache.TryGetValue(x) with
- | true, y -> y
- | false, _ ->
- let y = f x
- cache.Add(x, y)
- y
- memoizedF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement