Sha256: b4eb72c5eaa9884bc1445b733b254a41ce6878b7d7f9a32d9b7e6fd95b4b4561

Contents?: true

Size: 487 Bytes

Versions: 396

Compression:

Stored size: 487 Bytes

Contents

(ns raindrops
  (:require [clojure.string :refer [blank?]]))

(def ^:private sound-map
  { 3 "Pling"
    5 "Plang"
    7 "Plong" })

(defn- divisors
  [number]
  (filter
    (fn [[div sound]]
      (zero? (rem number div)))
    sound-map))

(defn- sounds-for
  [number]
  (let [divisors (divisors number)
        sounds (map last divisors)]
    (apply str sounds)))

(defn convert
  [number]
  (let [sounds (sounds-for number)]
    (if (blank? sounds)
      (str number)
      sounds)))

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/clojure/exercises/raindrops/src/example.clj
trackler-2.2.1.179 tracks/clojure/exercises/raindrops/src/example.clj
trackler-2.2.1.178 tracks/clojure/exercises/raindrops/src/example.clj
trackler-2.2.1.177 tracks/clojure/exercises/raindrops/src/example.clj
trackler-2.2.1.176 tracks/clojure/exercises/raindrops/src/example.clj
trackler-2.2.1.175 tracks/clojure/exercises/raindrops/src/example.clj
trackler-2.2.1.174 tracks/clojure/exercises/raindrops/src/example.clj
trackler-2.2.1.173 tracks/clojure/exercises/raindrops/src/example.clj
trackler-2.2.1.172 tracks/clojure/exercises/raindrops/src/example.clj
trackler-2.2.1.171 tracks/clojure/exercises/raindrops/src/example.clj
trackler-2.2.1.170 tracks/clojure/exercises/raindrops/src/example.clj
trackler-2.2.1.169 tracks/clojure/exercises/raindrops/src/example.clj
trackler-2.2.1.167 tracks/clojure/exercises/raindrops/src/example.clj
trackler-2.2.1.166 tracks/clojure/exercises/raindrops/src/example.clj
trackler-2.2.1.165 tracks/clojure/exercises/raindrops/src/example.clj
trackler-2.2.1.164 tracks/clojure/exercises/raindrops/src/example.clj
trackler-2.2.1.163 tracks/clojure/exercises/raindrops/src/example.clj
trackler-2.2.1.162 tracks/clojure/exercises/raindrops/src/example.clj
trackler-2.2.1.161 tracks/clojure/exercises/raindrops/src/example.clj
trackler-2.2.1.160 tracks/clojure/exercises/raindrops/src/example.clj