[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Doing away with "for"



|> | you can implement peano numbers 

|> Church numerals.  Peano arithmatic.  Grok lambda. :-)

Sure!  Like this, you mean:

; fn Compose f g {result @ x {$f <={$g $x}}}
; fn Succ n {result @ f {Compose <={$n $f} $f}}
; fn Plus m n {<={$m Succ} $n}
; fn Prod m n {result @ f {$m <={$n $f}}}
; fn Power m n {$m $n}
; One  =  $&result
; Two  =<={Succ $One}
; Three=<={Succ $Two}
; Nine =<={Prod $Three $Three}
; Twelve=<={Plus $Three $Nine}
; Twenty-Seven=<={Power $Three $Three}
; dots=@ x {result . $x}
; each @ x {echo <={<={$$x $dots} $x}} Three Nine Twelve Twenty-Seven
. . . Three
. . . . . . . . . Nine
. . . . . . . . . . . . Twelve
. . . . . . . . . . . . . . . . . . . . . . . . . . . Twenty-Seven
; 

- Harald