foldr f (head xs) xs is not the same as foldr1 f xs

Remi Turk rturk at science.uva.nl
Sun May 8 14:34:26 EDT 2005


On Sun, May 08, 2005 at 08:14:30PM +0200, David Sabel wrote:
> Hi!
> 
> A small example for the claim mentioned in the subject:
> 
> Prelude> let x = 1:undefined in foldr (curry fst) (head x) x
> 1
> Prelude> let x = 1:undefined in foldr1 (curry fst)  x
> *** Exception: Prelude.undefined
> 
> Perhaps it would be better to change the implementation of foldr1?

Why? *wonders what he's missing* It sounds like a rather silly
claim to me. When changed to

  foldr f (head xs) (tail xs)  is not the same as foldr1 f xs
                    ^^^^^^^^^

I would be more interested to see examples...

Greetings,
Remi

-- 
Nobody can be exactly like me. Even I have trouble doing it.


More information about the Glasgow-haskell-users mailing list