Yves Parès wrote:
I re-read recently a bit of RealWorldHaskell, and I saw something that
puzzles me now that I have a better understanding of the language.
It concerns the list concatenation being costful, and the need to use
another type like DList.
[] ++ ys = ys
(x:xs) ++ ys = x : (xs ++
On 13 October 2011 20:53, Albert Y. C. Lai tre...@vex.net wrote:
The number of new cons cells created in due course is Θ(length xs).
I was actually surprised by this because I expected: length(xs++ys) to
fuse into one efficient loop which doesn't create cons cells at all.
Unfortunately, I was
Wow, I don't get core haskell, but I get you point.
It's indeed odd foldl' doesn't use foldr (and sum doesn't use foldl' instead
of foldl as (+) is strict (*)) if foldr permits loop fusion.
(*) Anyway, is there a place where foldl is preferable over foldl' ? Never
happened to me, I always use
2011/10/14 Yves Parès limestr...@gmail.com:
(*) Anyway, is there a place where foldl is preferable over foldl' ?
To quote http://www.haskell.org/haskellwiki/Foldr_Foldl_Foldl' :
Usually the choice is between foldr and foldl', since foldl and
foldl' are the same except for their strictness
On Friday 14 October 2011, 16:55:14, Bas van Dijk wrote:
On 13 October 2011 20:53, Albert Y. C. Lai tre...@vex.net wrote:
The number of new cons cells created in due course is Θ(length xs).
I was actually surprised by this because I expected: length(xs++ys) to
fuse into one efficient loop
On Friday 14 October 2011, 17:10:00, Yves Parès wrote:
Wow, I don't get core haskell, but I get you point.
It's indeed odd foldl' doesn't use foldr (and sum doesn't use foldl'
instead of foldl as (+) is strict (*)) if foldr permits loop fusion.
No, it's not odd. The fusion technology isn't yet
On 11-10-12 06:50 PM, Yves Parès wrote:
[] ++ ys = ys
(x:xs) ++ ys = x : (xs ++ ys)
To me, we have here something that would be costful in a strict
language, but that here, thanks to guarded recursion ((:) being
non-strict), doesn't evaluate the first list until it is needed.
So let us
Okay, thanks.
I got to wonder that because I was implementing a Show instance (for a game
grid, like an Othello), and string manipulation usually comes with a heavy
usage of (++).
I'm just using a strict left-fold on the game grid (e.g. Vector (Maybe
Pawn)) with a combination of show (converting
On Thu, Oct 13, 2011 at 3:32 PM, Yves Parès limestr...@gmail.com wrote:
The number of new cons cells created in due course is Θ(length xs). These
cons cells would not have been created if we printed length xs and printed
length ys separately.
Okay, so the major problem comes from memory
Hello,
I re-read recently a bit of RealWorldHaskell, and I saw something that
puzzles me now that I have a better understanding of the language.
It concerns the list concatenation being costful, and the need to use
another type like DList.
[] ++ ys = ys
(x:xs) ++ ys = x : (xs ++ ys)
To me,
10 matches
Mail list logo