Skip to content

Instantly share code, notes, and snippets.

@tylerlrhodes
Created July 8, 2018 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylerlrhodes/b9302a3e7c698ae162940e09b09ce1b2 to your computer and use it in GitHub Desktop.
Save tylerlrhodes/b9302a3e7c698ae162940e09b09ce1b2 to your computer and use it in GitHub Desktop.
Scheme demo of higher order procedure
(define (sum term a next b)
(define (iter a result)
(if (> a b)
result
(iter (next a) (+ result (term a)))))
(iter a 0))
(define (identity x) x)
(define (inc x) (+ 1 x))
(sum identity 1 inc 10)
(define (cube x) (* x x x))
(sum cube 1 inc 10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment