This commit is contained in:
Ingy döt Net 2013-10-27 22:24:23 +00:00
parent 6f050a029e
commit 776bba907c
3887 changed files with 59894 additions and 7280 deletions

View file

@ -0,0 +1,11 @@
(defn squares-not-cubes
([] (squares-not-cubes (powers 2) (powers 3)))
([squares cubes]
(loop [[p2first & p2rest :as p2s] squares, [p3first & p3rest :as p3s] cubes]
(cond
(= p2first p3first) (recur p2rest p3rest)
(> p2first p3first) (recur p2s p3rest)
:else (cons p2first (lazy-seq (squares-not-cubes p2rest p3s)))))))
(->> (squares-not-cubes) (drop 20) (take 10))
; => (529 576 625 676 784 841 900 961 1024 1089)