On Wed, 19 Sep 2007, Stefan O'Rear wrote:
On Thu, Sep 20, 2007 at 04:17:54AM +0100, PR Stanley wrote:
Hi
length = foldr (. n . 1 + n) 0
Any idea how to define length with foldr. The above definition doesn't make
much sense.
Many thanks, Paul
or, in ASCII concrete syntax
length = foldr (\_ n -> 1 + n) 0
or
length = foldr (const succ) 0
:-) (But why foldr and not foldl' ? Working with lazy Peano numbers?)
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe