> Thanks,
> 
> but you are assuming that foldl evaluates the intermediate result right
> away.

It must

> My understanding of foldl is thus:
> 
> foldl (++) [] [[1],[2],[3],[4]]

[snip]

> -> [] ++ [1] ++ [2] ++ [3] ++ [4]
> 
> Which brings me back to my original question...

Well, you've removed the parentheses that give you the
information you want.

foldl (++) [] [[1],[2],[3],[4]]
-> foldl (++) ([] ++ [1]) [[2],[3],[4]]
-> foldl (++) (([] ++ [1]) ++ [2]) [[3],[4]]
-> foldl (++) ((([] ++ [1]) ++ [2]) ++ [3]) [[4]]
-> foldl (++) (((([] ++ [1]) ++ [2]) ++ [3]) ++ [4]) []
-> (((([] ++ [1]) ++ [2]) ++ [3]) ++ [4])

now you have to ask what has to be evaluated in order to get
the head of the result.

The answer is that you have to evaluate ((([] ++ [1]) ++
[2]) ++ [3]) before you can find it, and to get that, you
have to evaluate (([] ++ [1]) ++ [2]) and so on.


In the other case, you can get the head of (a:...)++ (b ++
c) by evaluating only the first steps of the first (++).


Does that help?

  J�n


-- 
J�n Fairbairn                                 [EMAIL PROTECTED]
31 Chalmers Road                                         [EMAIL PROTECTED]
Cambridge CB1 3SZ            +44 1223 570179 (after 14:00 only, please!)


_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to