all tasks
This commit is contained in:
parent
b83f433714
commit
68f8f3e56b
14735 changed files with 178959 additions and 0 deletions
19
Task/Y-combinator/Clojure/y-combinator-1.clj
Normal file
19
Task/Y-combinator/Clojure/y-combinator-1.clj
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
(defn Y [f]
|
||||
((fn [x] (x x))
|
||||
(fn [x]
|
||||
(f (fn [& args]
|
||||
(apply (x x) args))))))
|
||||
|
||||
(def fac
|
||||
(fn [f]
|
||||
(fn [n]
|
||||
(if (zero? n) 1 (* n (f (dec n)))))))
|
||||
|
||||
(def fib
|
||||
(fn [f]
|
||||
(fn [n]
|
||||
(condp = n
|
||||
0 0
|
||||
1 1
|
||||
(+ (f (dec n))
|
||||
(f (dec (dec n))))))))
|
||||
2
Task/Y-combinator/Clojure/y-combinator-2.clj
Normal file
2
Task/Y-combinator/Clojure/y-combinator-2.clj
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(defn Y [f]
|
||||
(#(% %) #(f (fn [& args] (apply (% %) args)))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue