<exp> ::= <integer-literal>
| <varref>
| ( <operator> <operands> )
<operator> ::= <exp>
<operands> ::= <exp>*
<varref> ::= <var>
> (run '(+ 1 2)) 3 > (run '(add1 (add1 3))) 5 > (run '(* (- (+ 1 2) 1) 2)) 4
> (run '(minus 3)) -3 > (run '(minus (minus 4))) 4
Use the list syntax and remember to modify your parser. A true value is one that is not numerically equal to 0.
> (run '(if (+ 1 2) 1 2)) 1 > (run '(if (- 1 1) (- 1 0) (* 20 5))) 100 > (run '(if + 1 2)) 1
> (run '(equal 3 3)) 1 > (run '(zero (sub1 5))) 0 > (run '(if (greater 2 3) 5 6)) 6
Write your answers to the exercises in a file (with comments, following the proper indentation rules), and send that file to
c311@lakshmi.cs.indiana.eduwith the subject line
4Assuming you've saved your homework in the file ``asgn.ss'' in the current directory, one way to submit is with the command:
Mail -s "4" c311@lakshmi.cs.indiana.edu < asgn.ssIf you use the
define-record stuff, include the expression
(load "define-record")in your submission.
Back to the c311 page
ehilsdal@cs.indiana.edu