[Haskell-cafe] Re: [Haskell] Recursive definition of fibonacci with Data.Vector

2010-03-08 Thread Henning Thielemann
On Sun, 7 Mar 2010, Edgar Z. Alvarenga 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)) Since I liked to have both element-wise lazy construction and

[Haskell-cafe] Re: [Haskell] Recursive definition of fibonacci with Data.Vector

2010-03-07 Thread Don Stewart
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

Re: [Haskell-cafe] Re: [Haskell] Recursive definition of fibonacci with Data.Vector

2010-03-07 Thread Alexander Solla
On Mar 7, 2010, at 12:56 PM, Don Stewart wrote: In fact, infinite vectors make no sense, as far as I can tell -- these are fundamentally bounded structures. Fourier analysis? Functional analysis? Hamel bases in Real analysis? There are lots of infinite dimensional vector spaces out

Re: [Haskell-cafe] Re: [Haskell] Recursive definition of fibonacci with Data.Vector

2010-03-07 Thread Don Stewart
ajs: On Mar 7, 2010, at 12:56 PM, Don Stewart wrote: In fact, infinite vectors make no sense, as far as I can tell -- these are fundamentally bounded structures. Fourier analysis? Functional analysis? Hamel bases in Real analysis? There are lots of infinite dimensional

Re: [Haskell-cafe] Re: [Haskell] Recursive definition of fibonacci with Data.Vector

2010-03-07 Thread Roman Leshchinskiy
On 08/03/2010, at 12:17, Alexander Solla wrote: GHC even optimizes it to: fib = fib Sounds like an implementation bug, not an infinite dimensional vector space bug. My guess is that strictness is getting in the way, and forcing what would be a lazy call to fib in the corresponding

Re: [Haskell-cafe] Re: [Haskell] Recursive definition of fibonacci with Data.Vector

2010-03-07 Thread Alexander Solla
On Mar 7, 2010, at 5:22 PM, Don Stewart wrote: Sorry for the overloading, I mean 'vector' in the sense of Data.Vector. Being strict in the length, its unclear to me that you can do much with infinite ones :-) Yeah, fair enough. I studied mathematics, not Haskell's Data.* hierarchy.