Re: [Haskell-cafe] Folding function composition: L or R?

7 Jul
2004
7 Jul
'04
12:31 p.m.
At 14:24 07/07/04 +0200, Henning Thielemann wrote:
On Wed, 7 Jul 2004, Graham Klyne wrote:
[[ sss :: [ShowS] sss = map (++) ["abc","def","ghi","jkl"]
ssr = foldr (.) id sss ssl = foldl (.) id sss
sr = ssr "" sl = ssl ""
-- sl == sr == "abcdefghijkl" -- is there any efficiency difference? ]]
Conventional wisdom suggests that foldr is better, but I'm not sure if it really matters in this case.
foldl performs worse, e.g. for infinite lists it will need infinite time :-)
Of course! And your answer makes me notice an important touchstone when dealing with such questions: "what happens with an infinite list?". Thanks! #g ------------ Graham Klyne For email: http://www.ninebynine.org/#Contact
7670
Age (days ago)
7670
Last active (days ago)
0 comments
1 participants
participants (1)
-
Graham Klyne