[Haskell] Recursive definition of fibonacci with Data.Vector
Edgar Z. Alvarenga
edgar at ymonad.com
Sun Mar 7 18:08:45 EST 2010
On Sun, 07/Mar/2010 at 17:04 -0500, Brian Sniffen wrote:
> To what do you expect 'v' to refer?
> Why use 'let' for the definition?
> And then once you sort it out to something like:
> fib = 0 `V.cons` (1 `V.cons` V.zipWith (+) fib (V.tail fib))
Was just a typo (the line above was copy from ghci).
> The three Vector operations used here are strict in the length of
> their arguments. So what length should 'fib' have? 2 more than its
> own length... which is more RAM than this computer has.
Ok, now I understood, is because of the strictness. The next time I
would look in the source code first.
> On Sun, Mar 7, 2010 at 3:49 PM, Edgar Z. Alvarenga <edgar at ymonad.com> wrote:
> > 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))
> > Cheers,
> > Edgar
> > _______________________________________________
> > Haskell mailing list
> > Haskell at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell
> Brian Sniffen
> <bts at evenmere.org>
More information about the Haskell