Function: rst-roman-to-arabic
rst-roman-to-arabic is a byte-compiled function defined in rst.el.gz.
Signature
(rst-roman-to-arabic STRING)
Documentation
Convert STRING of Roman numerals to an Arabic number.
If STRING contains a letter which isn't a valid Roman numeral, the rest of the string from that point onwards is ignored. Hence: MMD == 2500 and MMDFLXXVI == 2500.
Source Code
;; Defined in /usr/src/emacs/lisp/textmodes/rst.el.gz
(defun rst-roman-to-arabic (string)
;; testcover: ok.
"Convert STRING of Roman numerals to an Arabic number.
If STRING contains a letter which isn't a valid Roman numeral,
the rest of the string from that point onwards is ignored.
Hence:
MMD == 2500
and
MMDFLXXVI == 2500."
(cl-check-type string string)
(cl-check-type string (satisfies (lambda (s)
(not (equal s ""))))
"Roman number may not be an empty string.")
(let ((res 0)
(map rst-arabic-to-roman))
(save-match-data
(while map
(cl-destructuring-bind ((val &rest sym) &rest next) map
(if (string-match (concat "^" sym) string)
(setq res (+ res val)
string (replace-match "" nil t string))
(setq map next))))
(cl-check-type string (satisfies (lambda (s)
(equal s "")))
"Invalid characters in roman number")
res)))