Approximate overview
Academic
Cultural
Peer
Wellness
Misc
Express basic computations over primitive values and their associated standard library functions.
As you may know, some children enjoy using a language called “Pig Latin” (or Igpay Atlinlay). The normal rules for Pig Latin are as follows:
We’re going to do a simpler version of Pig Latin. For any word, we’ll strip the first letter from the beginning of the word, add the letter to the end, and add “ay”.
> (simplified-pig-latin "pig")
"igpay"
> (simplified-pig-latin "slurp")
"lurpsay" ; It's "uprslay" in traditional Pig Latin
> (simplified-pig-latin "append")
"ppendaay" ; It's "appendyay" in traditional Pig Latin
Write the simplified-pig-latin procedure.
Express basic computations over primitive values and their associated standard library functions.
As you’ve learned by now, the Unicode collating sequence assigns different numbers to the letters of the alphabet than humans do. We think #\a is the first letter of the alphabet; Racket calls it number 97.
Write a procedure, (nth-capital-letter n) that takes an integer between 1 and 26 as a parameter and returns the corresponding capital letter in English. (#\A is 1, #\B is 2, and so on and so forth.)
You may not write a huge conditional; you should write this procedure using the appropriate computation.
You should not use magic numbers; don’t rely on a particular collating sequence. (You may, however, assume that the letters appear in sequence in the collating sequence.)
> (nth-capital-letter 1)
#\A
> (nth-capital-letter 5)
#\E
> (nth-capital-letter 11)
#\K
NOTE: You can bring a sheet of hand-written notes or a stack of flashcards.
(TPS) What did you take away from the last lab?
I’ve taken questions from your reading responses, but you should always feel free to add your own.
Why does (or #f 0) evaluate to 0?
Although our tracer doesn’t show it (yet),
orevaluates its arguments by evaluating each in turn. When it hits the first non-false value, it returns that value. If it runs out of values, it returns false.
Why does (or 11 9) evaluate to 11?
See the prior answer.
11is “trueish” (that is, not false), so it returns it.
Why does (and #t 5) evaluate to 5?
Although our tracer doesn’t show it (yet),
andevaluates its arguments by evaluating each in turn. When it hits the first false, it returns false. If the last value is not false, it returns that value.
I won’t remember all of the procedures. Can I bring a sheet of notes or a stack of flashcards?
You may bring a sheet of hand-written notes or a stack of flashcards.
When can I take the quiz on Friday?
Both quizzes should be available at 8 a.m.
What file names would you like for the mini-project?
I think they are in the description. Perhaps not.
Why isn’t there a place to submit the mini-project on Gradescope?
Forthcoming.
Where is the grading rubric?
Tonight.
What’s this list procedure?
listtakes a bunch of expressions as parameters and puts them into a structure we call a “list” (surrounded by parentheses). Right now, all we know how to do with lists is (a) make them (withlist) and (b) find out how many values there are withlength.
I think we were just trying to show you that undefined values make your life difficult.
Where do you find the garbage (strike that, useful comments) that Sam types every day?
Go to the course Web site.
Go to the schedule.
Click on the subject of a class.
Cross your fingers.
If that doesn’t work, let Sam know.
A is closest to the board. A drives first. For today’s lab,
Sam is frantically updating Gradescope. (Done.)
Note: for median-of-three, don’t use min and max, just compare
x, y, and z to each other.
(<= x y z) is a shorthand for (and (<= x y) (<= y z))
(or (<= x y z) (<= z y x)) indicates that y is the median of x, y, z.
We will continue this lab next class!