Ch5 HW1
The purpose of this homework is for you to practice your Lisp program-writing skills. If you find yourself writing “Racket code”, ask for help before the end of the week!
-
(
addlength) (SC 3.12) Write a function that takes a list as input and returns a new list with the length of the input added onton the front of it.(addlength '(a big cat)) ==> '(3 a big cat) -
(
crank-call) (SC 3.14) (a) Without running the function: what is the result of(crank-call 'wanda 'fred)? (b) Modify the function so it behaves as a non-crank call using “quasiquote” but not “list”.(defun crank-call (caller callee) '(hello callee this is caller calling)) -
(SC Section 4.8, EX 4.14) Carefully state the rules for evaluating
andandor. What is(and 'a 'b)? What is(or nil 'bank 'money)? Give the results of each without typing them:(and ’fee ’fie ’foe) (or ’fee ’fie ’foe) (or nil ’foe nil) (and ’fee ’fie nil) (and (equal ’abc ’abc) ’yes) (or (equal ’abc ’abc) ’yes) -
(
same-sign) (SC, Page 124) Write a function(same-sign a b)that returns true ifaandbhave the same sign (choices: +,-, or 0). -
Get the handout and do exercise 6.41 (SC, Ex 6.41). Use the starter code that loads the house definition.