CSC 151 2019S, Class 30: Higher-order procedures, revisited
Overview
- Preliminaries
- Notes and news
- Upcoming work
- Extra credit
- Questions
- Key ideas
- Lab
- Mentor surveys
Preliminaries
News / Etc.
- Mentor sessions Thursday 7-8 p.m., Thursday 8-9 p.m., Sunday 5-6 p.m.
- Folks should think about taking CSC 161 in the fall. It’s a great class,
and you get to work with robots!
- I will need to leave class early today and Friday to observe a
colleague’s class. Friday we’ll do the quiz at the end of class.
Today we’ll have mentor surveys at the end of class.
Upcoming work
I would certainly appreciate suggestions of other extra credit activities
(preferably via email).
- Any student research week activity. (Still some on Thursday.)
- The Magic Flute, April 18, 7:00 p.m. Sebring-Lewis
- New: Dartanyan Brown discussion, 4pm Wednesday April 24, HSSC S3325
- New: Dartanyan Brown concert, 7:30 pm Wednesday April 24, Sebring-Lewis
- Track and Field at home this Saturday. (30 min)
- Women pole vault at about 10am
- Then men (noon?)
- Running likely to be between noon and 1pm
- Women’s Golf at Beloit this weekend.
- 30 Minutes of Mindfulness at SHACS (SHAW) every Monday 4:15-4:45
- Any organized exercise. (See previous eboards for a list.)
- 60 minutes of some solitary self-care activities that are unrelated to
academics or work. Your email reflection must explain how the activity
contributed to your wellness.
- 60 minutes of some shared self-care activity with friends. Your email
reflection must explain how the activity contributed to your wellness.
- CS Internship Hour, Thursday, 6:30-7:30 p.m., Noyce 3821.
Free Pizza.
- Participate in Kinetic Sculpture Competition: Saturday the 27th
- Public speaking workshop - April 22 at 7pm in HSSC S3325, with
Kathy Clemons-Beasley ‘05. “Kathy is the Global head of Leadership
and Manager Development for Blackrock and has been the speaker
coach for TEDxGC.”
- Clothing donation boxes in lounges. Donate!
Other good things
Questions
What’s my grade in the class?
(define grade
(lambda (participation cards labs hw project quizzes exams best)
(+ (* 0.05 participation) ; 90% is my default
(* 0.05 cards)
(* 0.10 labs)
(* 0.15 hw)
(* 0.10 project)
(* 0.10 quizzes)
(* 0.40 exams)
(* 0.05 best))))
Plus extra credit
(* 0.0025 num-extra-credit)
Key ideas
What did you see as the key (new) ideas from the reading?
- Seeing patterns is important in CS and programming.
- Once you see a pattern, you can write a procedure that encapsulates
that pattern, often by adding another procedure as a parameter, so
that you don’t have to write the whole same code again.
- l-s and r-s are there. They are like section, but simpler
- Looking for more general solutions is good.
- We’ve seen procedures that take other procedures as parameters, such
as
map. There’s nothing special about them; we could write them
ourselves.
- We can return procedures as results, generally by using an extra lambda
to describe the procedure.
- One new hop:
apply
Sectioning
(l-s proc x) = (section proc x <>)
(r-s prox x) = (section proc <> x)
(define l-s
(lambda (proc left) ; Inputs to l-s
(lambda (right) ; Input to the procedure created by l-s
(proc left right)))) ; Body of the procedure created by l-s
(define r-s
(lambda (proc right) ; inputs to r-s
(lambda (left) ; input to the new procedure
(proc left right)))) ; body
How is apply different than reduce?
Do the lab and you’ll figure it out.
How do we write procedures like map and + that take an unlimited
number of arguments.
Not covered yet. Ask me offline. More seriously, (lambda params body),
when you don’t put the params in parentheses, bundles all of the parameters
into a list, no matter how many there are.
(define num-params
(lambda params
(length params)))
> (num-params)
0
> (num-params 'a)
1
> (num-params 'a 'b 'c 'd)
4
> (num-params (list 'a 'b))
1
Lab
(define increment (section + 1 <>))
(define iota range)
(define square sqr)
Sam’s favorite quote of today’s class (approx): “The one with o is
the clearest, but I often forget to use o when I write programs.”
Writeup: Exercise 5
Mentor survey
The mentor and tutor surveys are an important part of our peer educator
program. Please take them seriously.