Created
October 4, 2019 06:03
-
-
Save lumie1337/3d7fb8a94b29884812488d3714210b28 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(s/def ::phrases (s/map-of number? string?)) | |
(def ^:private phrases {3 "Pling" 5 "Plang" 7 "Plong"}) | |
(s/fdef raindrops | |
:args (s/cat :n number?) | |
:ret string?) | |
(defn raindrops | |
"Returns number as string unless it is divisible by 3, 5 or 7, in which case it returns | |
the concatenation of the words Pling (3), Plang (5) and Plong (7) for the divisible cases." | |
[n] | |
(as-> phrases $ | |
(for [[d s] $ :when (= 0 (mod n d))] s) | |
(if (empty? $) (str n) (apply str $)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment