
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

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

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?)

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@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
participants (4)
-
Brandon S. Allbery KF8NH
-
Henning Thielemann
-
PR Stanley
-
Stefan O'Rear