Created
March 30, 2011 05:41
-
-
Save corani/893920 to your computer and use it in GitHub Desktop.
Reduce
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
Integer result = 0; | |
for (Integer value : items) { | |
result = result + value; | |
} |
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
from functools import reduce | |
result = reduce(lambda x, y: x + y, items) |
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
SELECT SUM(value) FROM items |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment