Ma réponse à ce problem ressemble trop à ces solutions in C.Projet Euler # 9 (triplets de Pythagore) dans Clojure
Quelqu'un a-t-il des conseils pour rendre cela plus lispy?
(use 'clojure.test)
(:import 'java.lang.Math)
(with-test
(defn find-triplet-product
([target] (find-triplet-product 1 1 target))
([a b target]
(let [c (Math/sqrt (+ (* a a) (* b b)))]
(let [sum (+ a b c)]
(cond
(> a target) "ERROR"
(= sum target) (reduce * (list a b (int c)))
(> sum target) (recur (inc a) 1 target)
(< sum target) (recur a (inc b) target))))))
(is (= (find-triplet-product 1000) 31875000)))
ressources Great ... merci. – dbyrne
+1 pour le lien! –