Jump to content

Y combinator: Difference between revisions

m
m (→‎{{header|Tailspin}}: syntax update)
Line 4,727:
// YCombinator is not needed since tailspin supports recursion readily, but this demonstrates passing functions as parameters
templates combinator@&{stepper:}
templates makeStep@&{rec:}
$ -> stepper@&{next: rec@&{rec: rec}} !
end makeStep
$ -> makeStep@&{rec: makeStep} !
end combinator
templates factorial
templates seed@&{next:}
<=0> 1 !
<>
$ * ($ - 1 -> next) !
end seed
$ -> combinator@&{stepper: seed} !
end factorial
Line 4,747:
templates fibonacci
templates seed@&{next:}
<..1> $ !
<>
($ - 2 -> next) + ($ - 1 -> next) !
end seed
$ -> combinator@&{stepper: seed} !
end fibonacci
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.