RosettaCodeData/Task/Roman-numerals-Decode/Common-Lisp/roman-numerals-decode-1.lisp
Ingy döt Net 6f050a029e update
2013-06-05 21:47:54 +00:00

6 lines
278 B
Common Lisp

(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)))