Skip to content

Instantly share code, notes, and snippets.

Created September 8, 2011 12:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1203334 to your computer and use it in GitHub Desktop.
Save anonymous/1203334 to your computer and use it in GitHub Desktop.
;; chouser's solution to Read Roman numerals
;; https://4clojure.com/problem/92
(fn [r]
(->>
(reverse r)
(map {\M 1000 \D 500 \C 100 \L 50 \X 10 \V 5 \I 1})
(cons 0)
(partition 2 1)
(reduce
(fn [t [b a]]
(+ t (if (< a b) (- a) a))) 0)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment