Lecture overview -- Keyboard shortcut: 'u'  Previous page: Higher-order functions -- Keyboard shortcut: 'p'  Next page: Linear search in lists -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Alphabetic index  Help page about these notes  Course home    Recursion and Higher-order Functions - slide 14 : 35

Some simple and general higher-order functions

We show three small, but useful higher-order functions

(define (flip f)
  (lambda (x y)
    (f y x)))
An alternative formulation of flip without use of the sugared define syntax.
(define (negate p)
  (lambda (x) 
    (if (p x) #f #t)))
(define (compose f g)
  (lambda (x)
    (f (g x))))
Go to exercise
Using flip, negate, and compose