[Haskell-cafe] length defined with foldr

Brandon S. Allbery KF8NH allbery at ece.cmu.edu
Wed Sep 19 23:22:15 EDT 2007


On Sep 19, 2007, at 23:17 , PR Stanley wrote:

> length = foldr (. n . 1 + n) 0
> Any idea how to define length with foldr. The above definition  
> doesn't make much sense.

Still fighting with the botched OCR?

length = foldr (\_ n -> 1 + n) 0

-- 
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery at kf8nh.com
system administrator [openafs,heimdal,too many hats] allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university    KF8NH




More information about the Haskell-Cafe mailing list