к
Size: a a a
к
D
D
D
к
D
к
к
к
к
D
к
D
D
import Debug.Trace (traceShowId)
fib :: Int -> Integer
fib = \i -> cache !! i
where
cache = fmap (fib' . traceShowId) [0..]
fib' 0 = 1
fib' 1 = 1
fib' n = cache !! (n - 2) + cache !! (n - 1)
main = print (fib 10)
-- 10
-- 9
-- 8
-- 7
-- 6
-- 5
-- 4
-- 3
-- 2
-- 1
-- 0
-- result: 89
к
к
к
к
к
D