[Haskell-cafe] length defined with foldr
Stefan O'Rear
stefanor at cox.net
Wed Sep 19 23:20:34 EDT 2007
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
length = foldr (λ_ n → 1 + n) 0
or, in ASCII concrete syntax
length = foldr (\_ n -> 1 + n) 0
Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070919/969204cb/attachment-0001.bin
More information about the Haskell-Cafe
mailing list