Re: [Haskell-cafe] A systematic method for deriving a defintion of foldl using foldr?

2009-03-14 Thread wren ng thornton
R J wrote: 2. I believe that the reverse implementation--namely, implementing foldr in terms of foldl--is impossible. What's the proof of that? As others have said, foldr in terms of foldl is impossible when infinite lists are taken into account. For finite lists it's easy though: (\f z

Re: [Haskell-cafe] A systematic method for deriving a defintion of foldl using foldr?

2009-03-13 Thread Henning Thielemann
On Wed, 11 Mar 2009, R J wrote: foldl and foldr are defined as follows:   foldr    :: (a - b - b) - b - [a] - b   foldr f e [] =  e   foldr f e (x : xs)   =  f x (foldr f e xs)   foldl    :: (b - a - b) - b - [a] - b   foldl f e [] =  e   foldl f e (x

[Haskell-cafe] A systematic method for deriving a defintion of foldl using foldr?

2009-03-11 Thread R J
foldl and foldr are defined as follows: foldr:: (a - b - b) - b - [a] - b foldr f e [] = e foldr f e (x : xs) = f x (foldr f e xs) foldl:: (b - a - b) - b - [a] - b foldl f e [] = e foldl f e (x : xs) = foldl f (f e x) xs 1.

Re: [Haskell-cafe] A systematic method for deriving a defintion of foldl using foldr?

2009-03-11 Thread Adrian Neumann
Read this excellent paper: http://www.cs.nott.ac.uk/~gmh/fold.pdf Am 11.03.2009 um 19:24 schrieb R J: foldl and foldr are defined as follows: foldr:: (a - b - b) - b - [a] - b foldr f e [] = e foldr f e (x : xs) = f x (foldr f e xs) foldl

Re: [Haskell-cafe] A systematic method for deriving a defintion of foldl using foldr?

2009-03-11 Thread Max Rabkin
2009/3/11 R J rj248...@hotmail.com: 2.  I believe that the reverse implementation--namely, implementing foldr in terms of foldl--is impossible.  What's the proof of that? That's correct. Consider their behaviour on infinite lists. --Max ___

Re: [Haskell-cafe] A systematic method for deriving a defintion of foldl using foldr?

2009-03-11 Thread Dan Doel
On Wednesday 11 March 2009 2:24:55 pm R J wrote: foldl and foldr are defined as follows: foldr:: (a - b - b) - b - [a] - b foldr f e [] = e foldr f e (x : xs) = f x (foldr f e xs) foldl:: (b - a - b) - b - [a] - b foldl f e [] =

Re: [Haskell-cafe] A systematic method for deriving a defintion of foldl using foldr?

2009-03-11 Thread Daniel Fischer
Am Mittwoch, 11. März 2009 19:24 schrieb R J: foldl and foldr are defined as follows: foldr:: (a - b - b) - b - [a] - b foldr f e [] = e foldr f e (x : xs) = f x (foldr f e xs) foldl:: (b - a - b) - b - [a] - b foldl f e [] = e

Re: [Haskell-cafe] A systematic method for deriving a defintion of foldl using foldr?

2009-03-11 Thread Ryan Ingram
2009/3/11 R J rj248...@hotmail.com: 3.  Any advice on how, aside from tons of practice, to develop the intuition for rapidly seeing solutions to questions like these would be much appreciated.  The difficulty a newbie faces in answering seemingly simple questions like these is quite