Skip to content

Instantly share code, notes, and snippets.

@cocoatomo
Forked from irof/Hoge.java
Last active December 10, 2015 08:18
Show Gist options
  • Save cocoatomo/4406867 to your computer and use it in GitHub Desktop.
Save cocoatomo/4406867 to your computer and use it in GitHub Desktop.
use Jython
#!/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