| Problem Set 5h | ||||||||||||||||||||||||||
Due date: 10/12 @ 11:59pm
Honors-section homework (Due date pushed back to Wednesday since it
went up late.)
HtDP Problems10.1.5, 10.1.6, 10.1.7, 10.1.8 Graphical Editor, RevisitedRe-develop your graphical editor from the last assignment using a slightly different data representation.
A 1String is a string, s, whose length is exactly
one, i.e. A list of 1Strings (Lo1String) is one of:
Revise the Editor data defintion from the first part of the last assignment to only use 1Strings and Lo1Strings: (define-struct editor (pre post)) ;; An Editor is a (make-editor Lo1String Lo1String) Re-develop the editor program using this new definition (Exercise 1-5). Exercise 6: Discuss the design trade-off in a paragraph of 20 to 30 words. (We will deduct points for each word in excess of 30.) Pocket CalculatorIn this part of the assignment you will develop the basic pieces of a small pocket calculator for arithmetic expressions. An arithmetic expression can either be a number, a variable, a unary operation applied to one argument, or a binary operation applied to two arguments. So for example, 3 + 4 is an arithmetic expression -- the binary operation + is applied to the arithmetic expressions 3 and 4. Arithmetic expressions nest of course, and we use parenthesis to indicate the nesting, so for example, (1 / 2) * (x + (3 + 4)) is an arithmetic expression. The basic operations are (unary) -, which flips the sign of its argument, and (binary) -, +, *, /, which perform subtraction, addition, multiplication, and division, respectively. Exercise 7: Develop a data definition for arithmetic expressions without variables.
Exercise 8: An expression that contains no variables can
be evaluated. For example, 3 + 4 evaluates
to 7. Develop a program Exercise 9: Develop a data definition for arithmetic expressions that may contain variables. Hint: what can you reuse?
Exercise 10: Develop a program | |||||||||||||||||||||||||||
| last updated on Tue Nov 29 19:02:43 EST 2011 | generated with Racket |