A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
19
Task/Hamming-numbers/Clojure/hamming-numbers.clj
Normal file
19
Task/Hamming-numbers/Clojure/hamming-numbers.clj
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
(defn smerge [xs ys]
|
||||
(lazy-seq
|
||||
(let [x (first xs),
|
||||
y (first ys),
|
||||
[z xs* ys*]
|
||||
(cond
|
||||
(< x y) [x (rest xs) ys]
|
||||
(> x y) [y xs (rest ys)]
|
||||
:else [x (rest xs) (rest ys)])]
|
||||
(cons z (smerge xs* ys*)))))
|
||||
|
||||
(defn smerge3 [xs ys zs]
|
||||
(smerge xs (smerge ys zs)))
|
||||
|
||||
(defn map*n [n ks] (map #(* n %) ks))
|
||||
|
||||
(def hamming
|
||||
(lazy-seq
|
||||
(cons 1 (smerge3 (map*n 2 hamming) (map*n 3 hamming) (map*n 5 hamming)))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue