Created
November 11, 2013 19:28
-
-
Save maryrosecook/7418874 to your computer and use it in GitHub Desktop.
FP
This file contains 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
e |
illerucis
commented
Nov 11, 2013
names = ["alice", "bob", "cynthia"]
codenames = map(lambda x: hash(x), names)
print codenames
people = [{'name': 'Mary', 'height': 160},
{'name': 'Isla', 'height': 80},
{'name': 'Sam'}]
def average_height(people):
people_with_heights = filter(lambda x: 'height' in x, people)
heights = map(lambda x: x['height'], people_with_heights)
total = reduce(lambda acc, x: acc + x, heights, 0)
return total/len(heights)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment