-
-
Save cocoatomo/4406867 to your computer and use it in GitHub Desktop.
use Jython
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
#!/usr/bin/env jython | |
# -*- coding: utf-8 -*- | |
class Fuga(object): | |
def __init__(self, color, weight): | |
self.color = color | |
self.weight = weight | |
if __name__ == '__main__': | |
lst = [Fuga('blue', 10), Fuga('red', 30), Fuga('blue', 50)] | |
weight = reduce(lambda acc, e: acc + e, | |
map(lambda it: it.weight, | |
filter(lambda it: it.color == 'blue', lst)), | |
0) | |
print(weight) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment