Created
July 10, 2011 04:26
-
-
Save dcsobral/1074264 to your computer and use it in GitHub Desktop.
error: forward reference extends over definition of value next
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
def iterationForCoin(stream: Stream[Int], coin: Int) = { | |
val (lower, higher) = stream splitAt coin | |
val next: Stream[Int] = lower #::: (higher zip next map { case (a, b) => a + b }) | |
next.toList | |
} | |
val coins = List(1, 2, 5, 10, 20, 50, 100, 200) | |
coins.foldLeft(1 #:: Stream.fill(200)(0))(iterationForCoin).last |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok, solved it like this: