Skip to content

Instantly share code, notes, and snippets.

@whamtet
Created February 28, 2021 01:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whamtet/1025b89d10f55ca9ccd76dee1549acca to your computer and use it in GitHub Desktop.
Save whamtet/1025b89d10f55ca9ccd76dee1549acca to your computer and use it in GitHub Desktop.
(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