; CS 61A HW 11 ; Name: ; Login: ; TA: ; Section: (define (check standard test-value) (if (not (equal? standard test-value)) (error "" test-value " differs from " standard))) ;;;; Core Questions ;;;; Q2 (define (ordered? num-lst) ; *** YOUR CODE HERE *** #f) (define (check2) (check #t (ordered? '(1 2 3 4 5))) (check #f (ordered? '(1 5 2 4 3)))) ;;;; Q3 (define (deep-map fn lst) ; *** YOUR CODE HERE *** #f) (define (check3) (check '(1 4 (9 16 (25 36) 49 64) (81 100)) (deep-map (lambda (x) (* x x)) '(1 2 (3 4 (5 6) 7 8) (9 10)))) (check '(they (rainy (iny)) spainy) (deep-map (lambda (x) (word x 'y)) '(the (rain (in)) spain)))) ;;;; Reinforcement Questions ;;;; Q5 (define (substitute lst old-wd new-wd) ; *** YOUR CODE HERE *** lst) (define (check5) (check '((lead axe) (bass axe) (rhythm axe) drums) (substitute '((lead guitar) (bass guitar) (rhythm guitar) drums) 'guitar 'axe))) ;;;; Q6 (define (substitute2 lst old-wd-lst new-wd-lst) ; *** YOUR CODE HERE *** lst) (define (check6) (check '((four calling birds) (three french hens) (two turtle doves)) (substitute2 '((4 calling birds) (3 french hens) (2 turtle doves)) '(1 2 3 4) '(one two three four)))) ;;;; Check all tests (define (check-all) (check2) (check3) (check5) (check6))