Functional Problem Solving (CSC 151 2016S) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Taking Notes] [Rubric]
Current: [Assignment] [EBoard] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards] [Labs] [Outlines] [Readings] - [Examples] [Handouts]
Reference: [Setup] [Remote] [VM] [Errors] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Curtsinger (2016S)] [Davis (2013F)] [Rebelsky (2015F)] [Weinman (2014F)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] - [Issue Tracker (Course)]
No one showed up. All you get are my preliminary notes.
Overview
Key idea: Use vector recursion.
(define vector-proc
(lambda (vec)
(let kernel ([pos 0])
(cond
[(= pos (vector-length vec)) ; Or something similar
base-value]
[(another-test)
base-value]
[else
(kernel (+ pos 1))]))))
We are returning a Boolean.
What should our base values be?
We've seen something similar on an exam (or at least I think we have).
We know that append requires 1 call to cons for each value in the first
list.
So, to reverse a list of length n using list-reverse-1 ...
So 1+2+3+...+n, which we now know is n(n+1)/2.
Alternately, you could work out the steps by hand.
There were none.