Beware of mathematicians and all those who make empty prophecies. The danger already exists that the mathematicians have made covenant with the devil to darken the spirit and to confine man in the bonds of hell.-St. Augustine
Examples:
(sumlist '()) ; 0 (sumlist '(1 2 3 4 5 6 7 8 9)) ; 45
(define (map-reverse f lis) (reverse (map f lis)))Examples:
(map-reverse car '((a b) (c d) (e f) (g h))) ; (g e c a) (map-reverse - '(1 -2 3 -4 5)) ; (-5 4 -3 2 -1)
(define (foo x y) (cond ((null? x) y) ((pair? x) (foo (car x) (foo (cdr x) y))) (else (cons x y))))Draw the call graph of (foo '(((a) b) c d) '(e f)). Use the return arrows to indicate all tail recursion. Note that foo calls itself twice: once tail-recursively and the other time non-tail-recursively.
You should include a generic animal object, amphibian object, mamal object, reptile object, primate object, and an object for each particular species. All the final animal objects should respond to each of the following messages:
has-thumbs?, biped?, slimy?, hairy?, eye-count, enormous?, sound, sex, flies?, lays-eggs?.
Put all methods as high up the hierarchy as possible, overriding them as necessary.
Examples:
(send dumbo 'flies?) ; #t (send barak 'flies?) ; #f (send barak 'eye-count) ; 2 (send kermit 'has-thumbs?) ; #f (send fiona 'lays-eggs?) ; #f (send kermit 'lays-eggs?) ; #t (send fifi 'enormous?) ; #f (send gertrude 'enormous?) ; #t (send mrs-piggy 'sex) ; female
foo(x) { list y = empty_list; l1: if (x == empty_list) return y; y = cons( car(x), y); x = cdr(x); goto L1; }
The file should be legal scheme code, with comments indicating which fragment of code corresponds to which problem.
You are allowed to make corrections, because the last submit command supersedes all previous submissions.Turn in the call graph for problem 2 by either (1) handing it in before class, (2) slipping it under the door to FEC 355C, or (3) submitting a postscript file which we can print.