Created
October 3, 2014 00:05
-
-
Save davejachimiak/942f7d25c4f4716e0771 to your computer and use it in GitHub Desktop.
tree-recursive solution to the counting change problem, pg. 41 SICP
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
| countChange :: Integer -> [Integer] -> Integer | |
| countChange amount denominations | |
| | null denominations || amount < 0 = 0 | |
| | amount == 0 = 1 | |
| | otherwise = countChange amount (tail denominations) + countChange (amount - head denominations) denominations |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment