all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
10
Task/Y-combinator/Factor/y-combinator-1.factor
Normal file
10
Task/Y-combinator/Factor/y-combinator-1.factor
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
USING: fry kernel math ;
|
||||
IN: rosettacode.Y
|
||||
: Y ( quot -- quot )
|
||||
'[ [ dup call call ] curry @ ] dup call ; inline
|
||||
|
||||
: almost-fac ( quot -- quot )
|
||||
'[ dup zero? [ drop 1 ] [ dup 1 - @ * ] if ] ;
|
||||
|
||||
: almost-fib ( quot -- quot )
|
||||
'[ dup 2 >= [ 1 2 [ - @ ] bi-curry@ bi + ] when ] ;
|
||||
5
Task/Y-combinator/Factor/y-combinator-2.factor
Normal file
5
Task/Y-combinator/Factor/y-combinator-2.factor
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
USING: kernel tools.test rosettacode.Y ;
|
||||
IN: rosettacode.Y.tests
|
||||
|
||||
[ 120 ] [ 5 [ almost-fac ] Y call ] unit-test
|
||||
[ 8 ] [ 6 [ almost-fib ] Y call ] unit-test
|
||||
Loading…
Add table
Add a link
Reference in a new issue