Skip to content

Instantly share code, notes, and snippets.

@dahlia
Forked from dinoSpeech/gist:3163386
Created July 25, 2012 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dahlia/3175089 to your computer and use it in GitHub Desktop.
Save dahlia/3175089 to your computer and use it in GitHub Desktop.
Higher-order function test suite
(define sum (make-aggregate + 0))
(sum (list 1 2 3)) ; 6
(define product (make-aggregate * 1))
(product (list 2 3 4)) ; 24
(define sum2 (make-aggregate (lambda (a b) (+ a b)) 0))
(sum2 (list 1 2 3)) ; 6
(define product2 (make-aggregate (lambda (a b) (* a b)) 1))
(product2 (list 2 3 4)) ; 24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment