Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
12
Task/Roman-numerals-Encode/XLISP/roman-numerals-encode.xlisp
Normal file
12
Task/Roman-numerals-Encode/XLISP/roman-numerals-encode.xlisp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
(defun roman (n)
|
||||
(define roman-numerals '((1000 "m") (900 "cm") (500 "d") (400 "cd") (100 "c") (90 "xc") (50 "l") (40 "xl") (10 "x") (9 "ix") (5 "v") (4 "iv") (1 "i")))
|
||||
(defun romanize (arabic-numeral numerals roman-numeral)
|
||||
(if (= arabic-numeral 0)
|
||||
roman-numeral
|
||||
(if (>= arabic-numeral (caar numerals))
|
||||
(romanize (- arabic-numeral (caar numerals)) numerals (string-append roman-numeral (cadar numerals)))
|
||||
(romanize arabic-numeral (cdr numerals) roman-numeral))))
|
||||
(romanize n roman-numerals ""))
|
||||
|
||||
; test the function:
|
||||
(display (mapcar roman '(10 2016 800 2769 1666 476 1453)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue