This outline is also available in PDF.
Held: Monday, April 26, 2010
We revisit the topic of higher-order procedures, one of the most
important techniques in languages like Scheme. Higher-order procedures
are procedures -- like
compose -- 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)
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 Tue May 11 09:03:15 2010.
The source to the document was last modified on Thu Jan 21 13:05:08 2010.
This document may be found at
You may wish to validate this document's HTML ; ;Samuel A. Rebelsky, firstname.lastname@example.org
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.