Created
April 12, 2016 22:07
-
-
Save BBischof/e57cd5c69573624c8e1db4160431f734 to your computer and use it in GitHub Desktop.
I like this example of grabbing elements from a List until you reach your desired sum.
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
{ var sum = 0; (1 to 10000) takeWhile { i => sum += i; sum <= 100 } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment