Created
February 28, 2021 01:44
-
-
Save whamtet/1025b89d10f55ca9ccd76dee1549acca to your computer and use it in GitHub Desktop.
This file contains 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
(defn- pluralize [todo last-num done] | |
(if (empty? todo) | |
done | |
(let [[f & r] todo] | |
(recur | |
r | |
(if (number? f) f last-num) | |
(conj done | |
(if (coll? f) | |
((if (= 1 last-num) first second) f) | |
f)))))) | |
(defn format-plurals [fmt-str & args] | |
(apply format fmt-str (pluralize args nil []))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment