all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
9
Task/Y-combinator/Smalltalk/y-combinator.st
Normal file
9
Task/Y-combinator/Smalltalk/y-combinator.st
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
Y := [:f| [:x| x value: x] value: [:g| f value: [:x| (g value: g) value: x] ] ].
|
||||
|
||||
fib := Y value: [:f| [:i| i <= 1 ifTrue: [i] ifFalse: [(f value: i-1) + (f value: i-2)] ] ].
|
||||
|
||||
(fib value: 10) displayNl.
|
||||
|
||||
fact := Y value: [:f| [:i| i = 0 ifTrue: [1] ifFalse: [(f value: i-1) * i] ] ].
|
||||
|
||||
(fact value: 10) displayNl.
|
||||
Loading…
Add table
Add a link
Reference in a new issue