Lab 7
- The submission server.
- Check your exam grade!
- From
constolist: some brain teasers.Note: these exercises are not fundamental to computer science. However, doing them may help you better understand some output you see later on.
Look at the expressions below. Which ones represent the same list? How long is each list?
Hint: there are really only six distinct values described below. Go ahead and divide a piece of paper up into six boxes, and then put each expression where it belongs.
(you can test your answers by cut-and-pasting expressions into the Interactions Window and seeing if they come out the same. Or useequal?to be sure. Uselengthin the Interactions Window to verify how long each list is)empty(cons 1 empty)(list 1)(list)(cons 1 (cons 2 empty))(cons 1 (cons 2 (cons 3 empty)))(cons (cons 1 (cons 2 empty)) (cons 3 empty))(cons (cons 1 (cons 2 empty)) (cons (cons 3 (cons 4 empty)) empty))(list 1 2)(list 1 2 3)(list (cons 1 (cons 2 empty)) 3)(cons (list 1 2) (cons (list 3 4) empty))(list (list 1 2) 3)
In general, we urge you to use
consrather thanlistwithin the code for your functions. Thelistfunction is most appropriate for writing test data in your examples, because it is succinct and the reader can easily see, when looking at alistexpression, how many elements make up the list and what the elements themselves are (e.g., nested lists). - XML, HTML, Music, and more:
Now the "real" notes
Oh, and just because I'm pedantic:
;; An XHTML is a (cons Symbol (cons empty List-of-XHTML empty)) ;; A List-of-XHTML is one of: ;; - empty ;; - (cons String List-of-XHTML) ;; - (cons XHTML List-of-XHTML) ;; A List-of-string is one of: ;; - empty ;; - (cons String List-of-string)

0 Comments:
Post a Comment
<< Home