Functional Problem Solving (CSC 151 2013F) : Outlines
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [IRC] [Teaching & Learning] [Grading]
Current: [Assignment] [EBoard] [Lab] [Outline] [Partners] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Partners] [Readings]
Reference: [Setup] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Davis (2013F)] [Rebelsky (2010F)] [Weinman (2012F)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker (Course)]
Held: Wednesday, 20 November 2013
Back to Outline 43 - Association Lists. On to Outline 45 - Binary Search.
Summary
We revisit the topic of higher-order procedures, one of the most
important techniques in languages like Scheme. Higher-order procedures
are procedures -- like map, left-section, or compose -- that
take other procedures as parameters, return other procedures as values,
or both.
Related Pages
Overview
Administrivia
map) that take other procedures as parameters.left-section) that return other procedures.
(define apply-to-2-and-3
(lambda (proc)
(proc 2 3)))
(define adder
(lambda (n)
(lambda (x)
(+ x n))))
(define inc (adder 1))
The following are notes I wrote for past versions of the course. I probably won't discuss any/all in class.
all-real? and all-integer?add-5-to-each and multiply-each-by-5
(define redder
(lambda (amt)
(lambda (color)
(rgb ...))))
compose
<>boxcode
(define compose
(lambda (f g)
(lambda (x)
(f (g x)))))
(compose sin sqrt)(compose car reverse)left-section
(define left-section
(lambda (func left)
(lambda (right)
(func left right))))
(define l-s left-section)
(l-s + 2)(l-s * 2)
(define right-section
(lambda (func right)
(lambda (left)
(func left right))))
(define r-s right-section)
map is the standard example.
(define map
(lamda (fun lst)
(if (null? lst)
null
(cons (fun (car lst))
(map fun (cdr lst))))))
(define all-numbers?
(lambda (lst)
(or (null? lst)
(and (pair? lst)
(number? (car lst))
(all-numbers? (cdr lst))))))
(define all-symbols?
(lambda (lst)
(or (null? lst)
(and (pair? lst)
(symbol? (car lst))
(all-symbols? (cdr lst))))))
(define all
(lambda (test? lst)
(or (null? lst)
(and (pair? lst)
(test? (car lst))
(all test? (cdr lst))))))
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [IRC] [Teaching & Learning] [Grading]
Current: [Assignment] [EBoard] [Lab] [Outline] [Partners] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Partners] [Readings]
Reference: [Setup] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Davis (2013F)] [Rebelsky (2010F)] [Weinman (2012F)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker (Course)]
Samuel A. Rebelsky, rebelsky@grinnell.edu
Copyright (c) 2007-2013 Janet Davis, Samuel A. Rebelsky, and Jerod Weinman. (Selected materials are copyright by John David Stone or Henry Walker and are used with permission.)

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this
license, visit http://creativecommons.org/licenses/by-nc/3.0/
or send a letter to Creative Commons, 543 Howard Street, 5th Floor,
San Francisco, California, 94105, USA.