1. let memoize (f : 'a -> 'b) =
  2.     let cache = new Dictionary<'a, 'b>()
  3.    
  4.     let memoizedF x =
  5.         match cache.TryGetValue(x) with
  6.         | true, y -> y
  7.         | false, _ ->
  8.             let y = f x
  9.             cache.Add(x, y)
  10.             y
  11.  
  12.     memoizedF
  13.