A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
24
Task/Man-or-boy-test/Clojure/man-or-boy-test.clj
Normal file
24
Task/Man-or-boy-test/Clojure/man-or-boy-test.clj
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
(declare a)
|
||||
|
||||
(defn man-or-boy
|
||||
"Man or boy test for Clojure"
|
||||
[k]
|
||||
(let [k (atom k)]
|
||||
(a k
|
||||
(fn [] 1)
|
||||
(fn [] -1)
|
||||
(fn [] -1)
|
||||
(fn [] 1)
|
||||
(fn [] 0))))
|
||||
|
||||
(defn a
|
||||
[k x1 x2 x3 x4 x5]
|
||||
(let [k (atom @k)]
|
||||
(letfn [(b []
|
||||
(swap! k dec)
|
||||
(a k b x1 x2 x3 x4))]
|
||||
(if (<= @k 0)
|
||||
(+ (x4) (x5))
|
||||
(b)))))
|
||||
|
||||
(man-or-boy 10)
|
||||
Loading…
Add table
Add a link
Reference in a new issue