RosettaCodeData/Task/Roman-numerals-Decode/Common-Lisp/roman-numerals-decode-1.lisp

7 lines
278 B
Common Lisp
Raw Permalink Normal View History

2013-06-05 21:47:54 +00:00
(defun mapcn (chars nums string)
(loop as char across string as i = (position char chars) collect (and i (nth i nums))))
(defun parse-roman (R)
(loop with nums = (mapcn "IVXLCDM" '(1 5 10 50 100 500 1000) R)
as (A B) on nums if A sum (if (and B (< A B)) (- A) A)))