

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Wright State University Department of Computer Science and Engineering
CS 784 Fall 2008 Prasad
Define a function distinctSymbols that takes a nested list of numbers and symbols as input, and returns a flat list of distinct symbols in the input. (In other words, the length of the resulting flat list must be the count of the distinct symbols in the input nested list.)
(distinctSymbols โ(1)) returns () (distinctSymbols โ(256 x (y))) returns (x y) (distinctSymbols โ(((a)) b (2 (a) (c c c))))) returns (a b c)
Consider the following mystery function.
(define (mystery n) (letrec ( (AUX (lambda (n s) (if (zero? n) (list s) (append (AUX (- n 1) (cons 0 s)) (AUX (- n 1) (cons 1 s)) ) ) ) ) ) (AUX n ()) ) )
What is the value of (mystery 2)? (Hint: Trace the code bottom-up carefully.) Describe the value returned when mystery is invoked with a natural num- ber. (Hint: Reason inductively.)
You are required to specify the ADT Int that supports the following integer operations: zero, succ, pred, negate, plus, and minus. Informally,