This outline is also available in PDF.
Held: Tuesday, 17 November 2009
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.
The following is variant of something John Stone says ...
(define redder (lambda (amt) (lambda (color) (rgb ...))))
(define compose (lambda (f g) (lambda (x) (f (g x)))))
(compose sin sqrt)
(compose car reverse)
(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))
mapis 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))))))
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
You may wish to validate this document's HTML ; ;Samuel A. Rebelsky, email@example.com
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.