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
Apply vs. map example
map and apply both take a procedure and a list as inputs.map applies the procedure to each element, one at a time, and
creates a new list.apply takes all of the list elements as input to one function call.Examples
> (map list (list 1 2 3 4))
'((1) (2) (3) (4))
> (apply list (list 1 2 3 4))
'(1 2 3 4)
Exercise 2: Which do you prefer?
v4: It's concisev4: It's the most readablev2: It's the most readableExercise 3: Dot-Product
If your brain is sufficiently mangled, this is kinda fun.
(define dot-product (compose (l-s apply +)
(section map * <> <>)))
Exercise 4:
Exercise 5: Please write up this exercise