Created
July 8, 2018 18:40
-
-
Save tylerlrhodes/b9302a3e7c698ae162940e09b09ce1b2 to your computer and use it in GitHub Desktop.
Scheme demo of higher order procedure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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