| Paste number 20157: | memoize |
| Pasted by: | sjanssen |
| 2 years, 7 months ago | |
| #haskell | |
| Paste contents: |
| import Array f :: Integer -> Integer f x | x <= 256 = arr ! x | otherwise = pureF x where pureF y = 2^y arr = array (0, 256) [(i, pureF i) | i <- [0..256]] |
Annotations for this paste:
| Annotation number 1: | CAF in where |
| Pasted by: | sjanssen |
| 2 years, 7 months ago | |
| Paste contents: |
| import Array import Debug.Trace f :: Integer -> Integer f x | x <= 256 = arr ! x | otherwise = pureF x where pureF y = trace (show y) 2^y arr = array (0, 256) [(i, pureF i) | i <- [0..256]] main = print $ sum $ map f [1..10] |