> (cond->if '(cond ((= x 1) 'foo) ((= x 2) 'bar) (else 'error))) (if (= x 1) (quote foo) (if (= x 2) (quote bar) (quote error))) >You may assume that every cond expression has an else part.
(define foo (lambda (<symbol>*) <tail expression>))
An expression is a <tail expression> with respect to foo if it contains no applications of foo:
<expression>
(foo <expression>*)
where <symbol>* is zero or more symbols, <expression> is an expression which contains no applications of foo, <expression>* is zero or more expressions which contain no applications of foo, and <tail expression> is an expression which is tail recursive with respect to foo. Write a function, tail?, which takes a function definition as an argument, and returns #t if the defined function is a <tail function> and #f otherwise. For example:
> (tail? '(define fact (lambda (x acc) (if (= x 0) acc (fact (- x 1) (* x acc)))))) #t > (tail? '(define fact (lambda (x) (if (= x 0) 1 (* (fact (- x 1))))))) #f >
* This webpage is located at http://cs.unm.edu/~williams/cs257/project1f01.html