Functional Problem Solving (CSC 151 2015F) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Taking Notes] [Rubric] [Remote Access]
Current: [Assignment] [EBoard] [Lab] [Outline] [Reading]
Sections: [Assignments] [EBoards] [Labs] [Outlines] [Readings] - [Examples] [Handouts]
Reference: [Setup] [VM] [Errors] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Curtsinger (2015F)] [Davis (2013F)] [Rebelsky (2015S)] [Weinman (2014F)]
Misc: [Submit Questions] - [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] - [Issue Tracker (Course)]
Overview
map-like
procedures: (all pred? lst) and (any pred? lst). They do what you'd
expect.repeat and for-each.Can we look at any and all?
> (all odd? (list 1 3 11 23))
#t
> (all odd? (iota 5))
#f
> (any odd? (iota 5))
#t
> (any odd? (list 'sam 'erin 'zachary))
. . lib/gigls/higher.rkt:44:13: odd?: contract violation
expected: integer
given: 'sam
> (all odd? null)
#t
> (any odd? null)
#f
> (all even? null)
#t
> (all weird? null)
. . weird?: undefined;
cannot reference an identifier before its definition
(all odd? null)
should be true. (Similar argument for any.)For the pair-a-dice problem, you may find it helpful to write
(define tally-seven-eleven
(lambda (n)
(display (list "tallying" n "more dice")) (newline)
...))
Writeup is 3d or 4a