CSC 151.01, Class 22: Revisiting Lists
Overview
- Preliminaries
- Notes and news
- Upcoming work
- Extra credit
- Questions
- Lab
- Debrief
News / Etc.
- Continue partners!
- While our lab grader seems to be on top of things, our homework grader seems to be having trouble keeping up. I’m looking to hire an additional homework grader. I apologize for the difficulties. I hope things will be resolved soon.
- Strike policy reminder. I respect the student initiative on this issue. But you should have something to strike against. I will still teach class. I will not penalize you for missing class if you send me a one-paragraph reflection on some aspect of the strike.
- New policy forthcoming.
Rotating reminders
- Visit me in my office! I’m always happy to see students during my office hours. I prefer that you book me at https://rebelsky.youcanbook.me, but you can also just show up during office hours and hope that I’m not busy.
- Note that my office hours have been filling as of late. Talk to me individually if you can’t find a booking time.
Upcoming Work
- Assignment 5 due TONIGHT at 10:30 p.m.
- Lab writeup: TBD
- Reading: Recursion basics
- Exam 2 arrives tomorrow.
Extra credit (Academic/Artistic)
- CS Table, Tuesday at noon: Facial Recognition “algorithms”
- W. Kamau Bell, Tuesday at 6pm, Harris.
- Prazak Quartet, Tuesday, 28 February 2017, 7:30 p.m., Herrick.
- CS Extras, Thursday at 4:15 pm, Sam’s research and PM’s research
Extra credit (Peer)
Extra credit (Misc)
- Non-violent protest training session TODAY at 4:00 in JRC 101.
- Preventing sexual assault, Tuesday at 11am, JRC 101
- Host a prospective student THIS COMING WEEKEND. (March 5, April 8, April 23)
- Write the eboard equivalent for class Tuesday, Wednesday, or Friday next week. (Done. They will be Amazingly Terse)
Good things to do
- Bagel party in Math commons, Thursday, 7-9 pm. Lox status unclear.
Questions
- Can you use
mapon heterogeneous lists? - Yes, provided the procedure can be applied to all elements of the list.
(map square (list 1 2 "three"))=> boom(map list (list 1 2 "three"))=>'((1) (2) ("three"))- What happens if I am working with multiple heterogeneous lists?
- As long as the procedure accepts the corresponding values, it’s fine.
(map + (list 1 2 3) (list 3 4 "five"))=> boom(map list (list 1 2 3) (list 3 4 "five"))=>'((1 3) (2 4) (3 "five"))- Oh no! How will we get help next Tuesday?
- Ask questions before Tuesday.
- Why can’t we use
mapwithdefine? defineis not a procedure.
Lab
- How do you pronounce these words?
caris pronounced how it looks, unless you are Wicked Neat, in which case you pronounce it “cah”.cdris pronounced “could - err”. Of course,couldis a strange word. I really need IPA. (International Phoentic Alphabet, not the beer.)cadris pronounced “cad - err”, with the “cad” you would use for a man who behaves inappropriately.cddris pronounced “could did err”.cdddris pronounced “could did id err”.- What is element 5 of the list
'("a" "b" "c" "d" "e" "f" "g")? - We start numbering at 0. So it’s “f”.
- What does it mean when we see a period right before the last element
- of something that looks like a list, as in
'(a . b)or '(a b c d e f . g).- It means it’s not quite a list, because the rightmost
consdid not take a list as its second parameter. - For now, you should take it as a sign that you’ve done something wrong.
- Why can we take
carandcdrof things that are not lists? - Because the John McCarthy (designer of Lisp) and his graduate student
(implementer of Lisp) allowed it as such in how they created
carandcdr. (car (cons X Y))=>X(cdr (cons X Y))=>Y
Debrief
See above.
Writeup
Write up exercise 5 from the lab on lists. Include 6P-style documentation.
``` ;;; Procedure: ;;; rectangularize ;;; Parameters: ;;; drawing, a drawing ;;; Purpose: ;;; Convert to an ellipse ;;; Produces: ;;; result, a drawing ;;; Preconditions: ;;; … ;;; Postconditions: ;;; (drawing-width result) = (drawing-width drawing) ;;; … (define rectangularize (lambda (drawing) …))
Send your solution to csc151-01-grader@grinnell.edu.
Title your email CSC 151.01 Writeup for Class 22 (YOUR FULL NAMES).