diff options
-rw-r--r-- | clojure/raindrops/src/raindrops.clj | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/clojure/raindrops/src/raindrops.clj b/clojure/raindrops/src/raindrops.clj index 8815f2d..fda3fef 100644 --- a/clojure/raindrops/src/raindrops.clj +++ b/clojure/raindrops/src/raindrops.clj @@ -1,15 +1,11 @@ (ns raindrops) (defn convert [number] - (def drops "") - - (if (== (mod number 3) 0) - (def drops (str drops "Pling"))) - (if (== (mod number 5) 0) - (def drops (str drops "Plang"))) - (if (== (mod number 7) 0) - (def drops (str drops "Plong"))) - - (if (= drops "") - (def drops (str number))) - drops) + (let [drops (apply str + (map (fn [factor string] + (if (== (mod number factor) 0) + string nil)) + [3 5 7] + ["Pling" "Plang" "Plong"]))] + (if (= drops "") + (str number) drops))) |