Talk:Y combinator: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 74: | Line 74: | ||
(define Y |
(define Y |
||
(lambda (f) |
(lambda (f) |
||
( |
((lambda (x) |
||
(f (delay (x x)))) |
|||
(lambda (x) |
|||
(f (delay (x x))))))) |
|||
</lang> |
</lang> |
||
but you have to call the function with <lang scheme>(force f)</lang> |
but you have to call the function with <lang scheme>(force f)</lang> |
||
Line 80: | Line 83: | ||
<lang scheme> |
<lang scheme> |
||
(define fact |
(define fact |
||
( |
(Y |
||
(lambda (f) |
|||
(lambda (n) |
|||
(if (zero? n) |
|||
1 |
|||
(* n ((force f) (- n 1)))))))) |
|||
</lang> |
</lang> |
||
''Edit: Err... I think I messed it up a little, it should be ok now.'' |
|||
[[Special:Contributions/93.144.202.116|93.144.202.116]] |
[[Special:Contributions/93.144.202.116|93.144.202.116]] |