Talk:Y combinator: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 68: | Line 68: | ||
:: Ta! --[[User:Paddy3118|Paddy3118]] 04:31, 12 September 2010 (UTC) |
:: Ta! --[[User:Paddy3118|Paddy3118]] 04:31, 12 September 2010 (UTC) |
||
=="Y" combinator in Scheme== |
|||
Actually, there is a way to implement the Y combinator in Scheme: |
|||
<lang scheme> |
|||
(define Y |
|||
(lambda (f) |
|||
(f (delay (Y f))))) |
|||
</lang> |
|||
but you have to call the function with <lang scheme>(force f)</lang> |
|||
example: |
|||
<lang scheme> |
|||
(define fact |
|||
(lambda (f) |
|||
(lambda (n) |
|||
(if (= n 0) 1 |
|||
(* n ((force f) (- n 1))))))) |
|||
</lang> |
|||
[[Special:Contributions/93.144.202.116|93.144.202.116]] |