Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • Isn't this caused by because the head is not lazy in Scala streams? (For example: stackoverflow.com/questions/13410659/…) I think Scalaz has lazy streams for this purpose. Commented Nov 17, 2014 at 20:23
  • Is the Stream provided as input, or are you generating random numbers as you go? If the latter, then why not create a recursion that generates a random number with each iteration, checks the sum and runs another iteration if needed? Commented Nov 17, 2014 at 20:36
  • @benji, I could do this, but I was hoping to have a solution that is built purely from the existing abstractions in the standard scala libraries. Commented Nov 17, 2014 at 21:21