Skip to content

Instantly share code, notes, and snippets.

Created May 23, 2011 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/986842 to your computer and use it in GitHub Desktop.
Save anonymous/986842 to your computer and use it in GitHub Desktop.
;; jneira's solution to Read Roman numerals
;; https://4clojure.com/problem/92
(fn rr [[f & [s & r :as nxt]]]
(condp #(or %1 %2) nil
({"IV" 4 "IX" 9 "XL" 40 "XC" 90 "CD" 400 "CM" 900}
(str f s)) :>> #(+ % (rr r))
({"I" 1 "V" 5 "X" 10 "L" 50 "C" 100 "D" 500 "M" 1000}
(str f)) :>> #(+ % (rr nxt))
0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment