Tagged: roman

Convert to Roman Numerals in Emacs Lisp

Sorry I can’t get the indents to export in org2blog. Maybe a configuration issue…

Just open it in Emacs, select the whole buffer, and intent-region

(defun ba-romani-numeri (number)
  "Provide the roman numeral for a number less than 4999"
(interactive)
(let* ((thousands (truncate (/ number 1000)))
       (thousands-remainder (- number (* 1000 thousands)))
       (roman-thousands (cond ((= 4 thousands) "MMMM")
                              ((= 3 thousands) "MMM")
                              ((= 2 thousands) "MM")
                              ((= 1 thousands) "M")
                              ((= 0 thousands) "")))
       (hundreds (truncate (/ thousands-remainder 100)))
       (hundreds-remainder (- thousands-remainder (* 100 hundreds)))
       (roman-hundreds (cond ((= 9 hundreds) "XM")
                             ((= 8 hundreds) "DCCC")
                             ((= 7 hundreds) "DCC")
                             ((= 6 hundreds) "DC")
                             ((= 5 hundreds) "D")
                             ((= 4 hundreds) "CD")
                             ((= 3 hundreds) "CCC")
                             ((= 2 hundreds) "CC")
                             ((= 1 hundreds) "C")
                             ((= 0 hundreds) "")))
       (tens (truncate (/ hundreds-remainder 10)))
       (tens-remainder (- hundreds-remainder (* 10 tens)))
       (roman-tens (cond ((= 9 tens) "XC")
                         ((= 8 tens) "LXXX")
                         ((= 7 tens) "LXX")
                         ((= 6 tens) "LX")
                         ((= 5 tens) "L")
                         ((= 4 tens) "XL")
                         ((= 3 tens) "XXX")
                         ((= 2 tens) "XX")
                         ((= 1 tens) "X")
                         ((= 0 tens) "")))
       (ones  tens-remainder)
       (roman-ones (cond ((= 9 ones) "IX")
                         ((= 8 ones) "VIII")
                         ((= 7 ones) "VII")
                         ((= 6 ones) "VI")
                         ((= 5 ones) "V")
                         ((= 4 ones) "IV")
                         ((= 3 ones) "III")
                         ((= 2 ones) "II")
                         ((= 1 ones) "I")
                         ((= 0 ones) ""))))
  (concat roman-thousands roman-hundreds roman-tens roman-ones)))
(ba-romani-numeri 2213)
;; "MMCCXIII"

(ba-romani-numeri 2013)
;; "MMXIII"

(ba-romani-numeri 999)
;; "XMXCIX"

(ba-romani-numeri 299)
;; "CCXCIX"

(ba-romani-numeri 99)
;; "XCIX"

(ba-romani-numeri 55)
;; "LV"

(ba-romani-numeri 35)
;; "XXXV"

(ba-romani-numeri 17)
;; "XVII"

(ba-romani-numeri 15)
;; "XV"

(ba-romani-numeri 5)
;; "V"

ARIDITAS IN CAMBRIA OSTENDIT RELIQUIAS ROMANAS

ARIDITAS PER CALORE SOLSTITII IN CAMBRIA CASTAM ROMANAM OSTENDIT.

VIRENS SICCI IN AGRO RELIQUIAS CASTI ROMANI ET ALIORUM OSTENDERUNT.

BBC News

https://i2.wp.com/news.bbcimg.co.uk/media/images/69213000/jpg/_69213128_aerialpic_1.jpg

http://www.bbc.co.uk/news/uk-wales-23628630

ANGLICE: The Summer drought in Wales unearths Roman discoveries

PRO VICIPAEDIO

UC:

  * '''[[10 Augusti]]''' — Ariditas Per Calore Solstitii in [[Cambria]] Castam Romanam Ostendit <sup>(''[http://www.bbc.co.uk/news/uk-wales-23628630 BBC News]'')</sup>

LC:

  * '''[[10 Augusti]]''' — ariditas per calore solstitii in [[Cambria]] castam romanam ostendit <sup>(''[http://www.bbc.co.uk/news/uk-wales-23628630 BBC News]'')</sup>