8.1. Lambda, Filter, Map, and Sorted#
8.1.1. Lambda#
lambda a function without a name;
anonymous functions
one line only
single expression only
stored in a variable
When do you use it?
Pass a function into another function as a parameter
lambda variables (comma separated): expression
lambda functions are used with other functions. Usually with map, filter, sort
8.1.2. Filter#
Uses
function
to test the truthiness of each value in the sequence and returns a filtered list.function
must return True or False
filter(function, sequence)
8.1.3. Map#
Uses
function
to transform the values in a sequence
map(function, sequence)
8.1.4. Sorted#
Uses
function
to sort values
sorted(sequence, key=function)