Created
September 4, 2016 16:41
-
-
Save groz/8d2694b0f7f0b011f1fe37ed519aef62 to your computer and use it in GitHub Desktop.
count change in mit-scheme
This file contains hidden or 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 (count-change coins amount) | |
(display coins) (newline) | |
(display amount) (newline) | |
(cond | |
((= 0 amount) 1) | |
((< amount 0) 0) | |
((null? coins) 0) | |
(else | |
(+ | |
(count-change coins (- amount (car coins))) | |
(count-change (cdr coins) amount) | |
) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment