Skip to content

Instantly share code, notes, and snippets.

@maryrosecook
Created November 11, 2013 19:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maryrosecook/7418874 to your computer and use it in GitHub Desktop.
Save maryrosecook/7418874 to your computer and use it in GitHub Desktop.
FP
@LeslieK
Copy link

LeslieK commented Nov 11, 2013

names = ['Mary', 'Isla', 'Sam']

print map(hash, names)

@jtakkala
Copy link

names = ['Mary', 'Isla', 'Sam']

codenames = map(lambda x: hash(x), names)

print names
print codenames

@illerucis
Copy link

def example_1():
    names = ['Mary', 'Isla', 'Sam']
    hashes = map(lambda x: hash(x), names)

@lealbaugh
Copy link

names = ["alice", "bob", "cynthia"]
codenames = map(lambda x: hash(x), names)
print codenames

@maryrosecook
Copy link
Author

people = [{'name': 'Mary', 'height': 160},
          {'name': 'Isla', 'height': 80},
          {'name': 'Sam'}]

@LeslieK
Copy link

LeslieK commented Nov 11, 2013

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