RosettaCodeData/Task/Square-but-not-cube/Clojure/square-but-not-cube.clj

10 lines
361 B
Clojure
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
(def squares (map #(* % %) (drop 1 (range))))
(def square-cubes (map #(int (. Math pow % 6)) (drop 1 (range))))
(def squares-not-cubes (filter #(not (= % (first (drop-while (fn [n] (< n %)) square-cubes)))) squares))
(println "Squares but not cubes:")
(println (take 30 squares-not-cubes))
(println "Both squares and cubes:")
(println (take 15 square-cubes))