| Paste number 20157: | memoize |
| Pasted by: | sjanssen |
| When: | 3 years, 1 month ago |
| Share: | Tweet this! | http://paste.lisp.org/+FJX |
| Channel: | #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 |
| When: | 3 years, 1 month ago |
| Share: | Tweet this! | http://paste.lisp.org/+FJX#1 |
| 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]