Memoization with recursion

前端 未结 3 473
醉梦人生
醉梦人生 2021-01-12 06:18

I am trying to understand Haskell realization of memoization , but I don\'t get how it works:

memoized_fib :: Int -> Integer
memoized_fib = (map fib [0..]         


        
3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-12 07:11

    map does not take three parameters here.

    (map fib [0..] !!)
    

    partially applies (slices) the function (!!) with map fib [0..], a list, as its first (left-hand) argument.

提交回复
热议问题