Skip to content

Instantly share code, notes, and snippets.

@okram999
Last active January 20, 2019 18:12
Show Gist options
  • Save okram999/3dce8bbbec83ac3b8d6090a3be251b3e to your computer and use it in GitHub Desktop.
Save okram999/3dce8bbbec83ac3b8d6090a3be251b3e to your computer and use it in GitHub Desktop.

Lamda

More like an annonymous function

even_num = lambda x: x%2 == 0

Map

Takes a functions/lambda and an iterable, and returns a map object. So convert to list

square = map(lambda x: x*2, [1,2,3,4,5,6]) #[2, 4, 6, 8, 10, 12]

Filters

Returns an object that holds true to the condition. Takes a functions/lambda and an iterable just like a Map

even = filter(lambda x: x%2 == 0, [1,2,3,4,5,6]) #[2, 4, 6]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment