
7 Mar
2010
7 Mar
'10
3:56 p.m.
edgar:
Hello,
why I can't define a recursive vector using Data.Vector, like in the example:
import qualified Data.Vector as V
let fib = 0 `V.cons` (1 `V.cons` V.zipWith (+) fib (V.tail v))
There's a typo: fib = 0 `V.cons` (1 `V.cons` V.zipWith (+) fib (V.tail fib)) Which let's it typecheck. But I don't think this is a sensible use of vectors. In fact, infinite vectors make no sense, as far as I can tell -- these are fundamentally bounded structures. GHC even optimizes it to: fib = fib (literally!). $ time ./A A: <<loop>> -- Don