Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Roman numerals were the numerical system of the Roman Empire. They use the letters I,V,X,L,C,D,M to represent positive integers. The Wikipedia entry on roman numerals

Roman numerals were the numerical system of the Roman Empire. They use the letters I,V,X,L,C,D,M to represent positive integers. The Wikipedia entry on roman numerals http://en.wikipedia.org/wiki/Roman_numerals describes rules for converting back and forth between Roman numerals and Arabic numerals.

Write a list set of Lisp functions to convert between the two numeric representations:

roman-to-arabic to convert a Roman numeral given as the list of its letters- to the corresponding Arabic numeral

arabic-to-roman to convert an Arabic numeral given as a regular number to the corresponding Roman numeral represented as a list of its letters.

For example:

(roman-to-arabic (M M X I I)) 2012

(arabic-to-roman 1977) (M C M L X X V I I)

NOTE: Your implementation must be consistent with the rules described in the Wikipedias roman numerals entry.

you may only use the following LISP functions and predicates (car x) (cdr x) (cons x y) (atom x) (null x) (eq x y) (equal x y) (numberp x) (listp x) (eval y) (funcall x ...) (apply x y) special forms (including logic connectives) (defun ...) (defmacro ...) (let ((x y) (u v)...) z) (lambda (x y) ...) (quote x) and its short form 'x (function y) as well as #' `( ...) (list a1 a2 ...) (if x y z) (cond ... ) (and x y ...) (or x y ...) (not x) (mapcar f l) and numeric operators and comparisons such as (+ x y) (- x y) (* x y) (/ x y) (< x y) (mod x y) (floor x) (ceiling x) (> x y) (= x y) (<= x y) (>= x y)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions