- Haskell: Datastruture with O(1) append and O(1) indexing?
- import Data.Array
- fibs = listArray (0, n-1) $ 0 : 1 : [fibs!(i-1) + fibs!(i-2) | i <- [2..n-1]]
- where n = 100
- import Data.Vector.Unboxed as V
- fibs = constructN 100 f
- where f xs | i < 2 = i
- | otherwise = xs!(i-1) + xs!(i-2)
- where i = V.length xs