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)]
Overview
Is there a reason you gave us avec-set! and avec-get?
Mostly to help you think about recursion over association vectors. You will not use them directly in your solution.
In solving problems 1 and 2, should we use the $cons idea from exercise 2 on the lab on analyzing procedures.
Yes. Here's the important code.
(define car-counter (counter-new "car"))
(define cdr-counter (counter-new "cdr"))
(define cons-counter (counter-new "cons"))
(define null?-counter (counter-new "null?"))
(define $car
(lambda (lst)
(counter-count! car-counter)
(car lst)))
(define $cdr
(lambda (lst)
(counter-count! cdr-counter)
(cdr lst)))
(define $cons
(lambda (val lst)
(counter-count! cons-counter)
(cons val lst)))
(define $null?
(lambda (val)
(counter-count! null?-counter)
(null? val)))
I seem to have null's in the middle of my vector on problem 2.
Then you probably need to shift values down to fill those in. A separate helper may be useful.
You do not have to use this strategy; There are other ways to solve this that are more efficient.
Should we insert comments to explain what our code is doing?
Sure.
Do you have hints on working on problem 3?
The types of the parameters should be obvious. (Look at how they are used.)
When you plug in appropriate sample values, you'll see what the procedure does.
Some careful thought should explain what
indianadoes.I'd suggest making
wisconsina separate procedure so that you can experiment with it.
Why can't I just use read for problem 4?
Because
readreads too much. See my sample file.
> (define source (open-input-file "/home/rebelsky/Desktop/morewords.txt"))
> (read source)
'SamR
> (symbol->string 'SamR)
"SamR"
> (read source)
'(who often writes parenthetical remarks)
How do we convert characters to strings?
Read the reference page.
How much extra credit have we accumulated on this exam?
Five points, so far.
Normal procedures.
Updated procedures.