buggy.romannum - ; ; ; ; Return the decimal value of the...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
; Return the decimal value of the Roman numeral whose digits are ; contained in roman-numeral. ; Roman-numeral is assumed to contain only Roman digits. ; Sample call: (decimal-value 'xiv), which should return 14. (define (decimal-value roman-numeral) (element-sum (prefix-values-removed (digit-values roman-numeral)))) ; Return a sentence containing the decimal values of the Roman digits ; in roman-numeral. ; Roman-numeral is assumed to contain only Roman digits. ; Sample call: (digit-values 'xiv), which should return (10 1 5). (define (digit-values roman-numeral) (if (empty? roman-numeral) '() (sentence (decimal-digit-value (first roman-numeral)) (digit-values (butfirst roman-numeral))))) ; Return the decimal value of the given Roman digit. (define (decimal-digit-value roman-digit) (cond ((equal? roman-digit 'm) 1000) ((equal? roman-digit 'd) 500) ((equal? roman-digit 'c) 100) ((equal? roman-digit 'l) 50) ((equal? roman-digit 'x) 10) ((equal? roman-digit 'v) 5) ((equal? roman-digit 'i)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/30/2010 for the course EECS 21281 taught by Professor Harvey during the Spring '10 term at University of California, Berkeley.

Page1 / 2

buggy.romannum - ; ; ; ; Return the decimal value of the...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online