Ch1 HW2
Warmups
- GREET-IZE: String -> (String->String). Take in a greeting. Return a function that takes in a name and outputs the string “greeting, name”.
 
(define-test TEST-GREET-IZE 
  "Verify you understand function-returning functions."
  (assert-equal "Hello, Doc" (funcall (greet-ize "Hello") "Doc"))
  (assert-equal "Goodbye, World" (funcall (greet-ize "Goodbye") "World")))
- WIPE-NESTED: List -> List. Change every non-list any nested list of the input to ‘BLACK.
 
(define-test TEST-WIPE
  "Make sure the structure of the list is retained when wiping."
  (assert-equal '(BLACK BLACK BLACK) (wipe-nested '(orange blue green)))
  (assert-equal '(BLACK (BLACK BLACK BLACK) BLACK ((BLACK)))
                (wipe-nested '(R (R G B) G ((B))))))
Homework
This is practice programming from Chapter 1.
- Function DUBL: doubles its input.
 - Write a single test for DUBL.
 - Function DUBLR: doubles every input in a list.
 - Colorizer: turns integers into color symbols: 1 -> 
'RED', 2 ->'WHITE, 10 ->'BLUE, any other becomes'NONE. - Function N-NER: takes in a number and a list. Adds the number to every element in the list (returning the new list).
 - Function MY-MAKE-SEQ: inputs are three numbers (a,b,c), output is a function that takes in a number x and puts out the list (x+a, x+b, x+c).
 - Write two tests for MY-MAKE-SEQ.