CS151.01 2009F Functional Problem Solving
[Skip to Body]
Primary:
[Front Door]
[Schedule]
-
[Academic Honesty]
[Instructions]
Current:
[Outline]
[EBoard]
[Reading]
[Lab]
-
[Assignment]
Groupings:
[Assignments]
[EBoards]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Projects]
[Readings]
References:
[A-Z]
[By Topic]
-
[Scheme Report (R5RS)]
[R6RS]
[TSPL4]
Related Courses:
[CSC151.02 2009S (Weinman)]
[CSC151.02 2009S (Davis)]
[CSC151 2008S (Rebelsky)]
Misc:
[SamR]
[MediaScript]
[GIMP]
Back to Association Lists. On to Binary Search.
This outline is also available in PDF.
Held: Tuesday, 17 November 2009
Summary:
We visit the topic of higher-order procedures, one of the most
important techniques in languages like Scheme. Higher-order procedures
are procedures, like map
, that take other procedures
as parameters, return other procedures as values, or both.
Related Pages:
Notes:
Overview:
map
.all?
.The following is variant of something John Stone says ...
all-real?
and all-integer?
add-5-to-each
and multiply-each-by-5
(define redder (lambda (amt) (lambda (color) (rgb ...))))
compose
(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)
(define smokes? (r-s vector-ref 3))
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))))))
Back to Association Lists. On to Binary Search.
[Skip to Body]
Primary:
[Front Door]
[Schedule]
-
[Academic Honesty]
[Instructions]
Current:
[Outline]
[EBoard]
[Reading]
[Lab]
-
[Assignment]
Groupings:
[Assignments]
[EBoards]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Projects]
[Readings]
References:
[A-Z]
[By Topic]
-
[Scheme Report (R5RS)]
[R6RS]
[TSPL4]
Related Courses:
[CSC151.02 2009S (Weinman)]
[CSC151.02 2009S (Davis)]
[CSC151 2008S (Rebelsky)]
Misc:
[SamR]
[MediaScript]
[GIMP]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Fri Dec 11 09:38:50 2009.
The source to the document was last modified on Fri Aug 21 17:03:06 2009.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2009F/Outlines/outline.43.html
.
You may wish to
validate this document's HTML
;
;
http://creativecommons.org/licenses/by-nc/2.5/
or send a letter to Creative Commons, 543 Howard Street, 5th Floor,
San Francisco, California, 94105, USA.