all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
27
Task/Y-combinator/Scheme/y-combinator.ss
Normal file
27
Task/Y-combinator/Scheme/y-combinator.ss
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
(define Y
|
||||
(lambda (f)
|
||||
((lambda (x) (x x))
|
||||
(lambda (g)
|
||||
(f (lambda args (apply (g g) args)))))))
|
||||
|
||||
(define fac
|
||||
(Y
|
||||
(lambda (f)
|
||||
(lambda (x)
|
||||
(if (< x 2)
|
||||
1
|
||||
(* x (f (- x 1))))))))
|
||||
|
||||
(define fib
|
||||
(Y
|
||||
(lambda (f)
|
||||
(lambda (x)
|
||||
(if (< x 2)
|
||||
x
|
||||
(+ (f (- x 1)) (f (- x 2))))))))
|
||||
|
||||
(display (fac 6))
|
||||
(newline)
|
||||
|
||||
(display (fib 6))
|
||||
(newline)
|
||||
Loading…
Add table
Add a link
Reference in a new issue