CSC151.02 2010S Functional Problem Solving : Reference

Higher-Order Procedures


Sectioning

(left-section binproc left)
Traditional Higher-Order Procedure. Given a two-parameter procedure and a value, creates a new anonymous one-parameter procedure by filling in the first (left) parameter of the procedure. The new procedure, when applied to a value, v, returns (binproc left v).
(right-section binproc right)
Traditional Higher-Order Procedure. Given a two-parameter procedure and a value, creates a new anonymous one-parameter procedure by filling in the second (right) parameter of the procedure. The new procedure, when applied to a value, v, returns (binproc v right).
(l-s binproc left)
Traditional Higher-Order Procedure. A shorthand for left-section.
(r-s binproc right)
Traditional Higher-Order Procedure. A shorthand for right-section.

Boolean Higher-Order Procedures

(^and f1 f2 ... fn)
Traditional Higher-Order Procedure. A higher-order version of and. Creates a new procedure that, when applied to some values, returns (and (f1 values) (f2 values) ... (fn values)).
(^or f1 f2 ... fn)
Traditional Higher-Order Procedure. A higher-order version of or. Creates a new procedure that, when applied to some values, returns (or (f1 values) (f2 values) ... (fn values)).
(^not pred?)
Traditional Higher-Order Procedure. A higher-order version of not. Creates a new procedure, that, when applied to some values, returns the opposite of pred?. That is, (1) if pred? returns a truish value when applied to some parameters, the new procedure returns #f when applied to those same parameters; (2) if pred? returns false when applied to some parameters, the new procedure returns #t when applied to those same parameters.

Miscellaneous Higher-Order Procedures

(compose f g)
Traditional Higher-Order Procedure. Build a one-parameter procedure that applies g to its parameter, and then f to that result. ((compose f g) x) is the same as (f (g x)).
(o f1 f2 ... fn-1 fn)
Traditional Higher-Order Procedure. Build a one-parameter procedure that applies each f, in turn, starting with fn and working backwards. The composition, when applied to a value, x, produces the same result as (f1 (f2 (... (fn-1 (fn x))))).
(constant value)
Traditional Higher-Order Procedure. Create a new function that always returns value, no matter what parameters it is applied to.

Creative Commons License

Samuel A. Rebelsky, rebelsky@grinnell.edu

Copyright (c) 2007-10 Janet Davis, Matthew Kluber, Samuel A. Rebelsky, and Jerod Weinman. (Selected materials copyright by John David Stone and Henry Walker and used by permission.)

This material is based upon work partially supported by the National Science Foundation under Grant No. CCLI-0633090. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.

This work is licensed under a Creative Commons Attribution-NonCommercial 2.5 License. To view a copy of this license, visit 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.