

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Assignment; Class: Programming Languages; Subject: Computer Science; University: University of Alabama - Birmingham; Term: Fall 2007;
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Due Thursday, October 18, 2007
I (one) V (five) X (ten) L (fifty) C (one hundred) D (five hundred) M (one thousand) These are usually written in linear order (e.g., I, II, III) with smaller numerals always following larger numerals except when they are to be subtracted (e.g., IV means 5 - 1). Subtractions are used instead of writing four consecutive occurrences of the same symbol (i.e., IV should be used instead of IIII, MCM instead of MDCCCC, etc.). Only symbols which are powers of 10 may be used in subtractions (i.e., I, X, C, and M). Furthermore, subtraction rules require that a symbol representing 10x^ may not precede any symbol larger than 10x+1^ (e.g., IC is not permitted to represent 99 but XC is 90). Write a LISP function (romanToDecimal RomanNumeral) which takes a Roman numeral as a list of digits and returns the decimal equivalent if the Roman numeral is well formed and error otherwise. Test your function as follows:
(a) (romanToDecimal โ(C D V)) โ 405 (b) (romanToDecimal โ(M M V I I)) โ 2007 (c) (romanToDecimal โ(M M M C M X C I X)) โ 3999 (d) (romanToDecimal โ(M I M)) โ error
(a) (matchDNA โ(A T G C) โ(A T G C A T A C G A)) โ ((A T G C A) (T A C G) (A)) (b) (matchDNA โ(A) โ(A T G C A T)) โ ((A) (T) (G C A T)) (c) (matchDNA โ(C G) โ(A T G C)) โ ((A T) (G C) nil) (d) (matchDNA โ(G A A T T C) โ(T G G A A T T C T)) โ ((T G G A A T T C T) nil nil)
input a; input b; k := 1; while (b > 0) loop b := b - 1; k := k * a; end loop; output k;
Assuming that the input file contains the integers 4 and 3 (i.e., the list <4, 3>), use the denotational semantics of Core to trace the interpretation of the program.