map()
The function receives two parameters, one is the function, and the other is Iterable
, map
the incoming function is applied to each element of the sequence in turn, and the result is Iterator
returned as a new one.
reduce
Apply a function to a sequence [x1, x2, x3, ...]
, the function must accept two arguments, and reduce
the result continues to accumulate with the next element of the sequence.
And map()
similarly, filter()
also accepts a function and a sequence. The map()
difference is that filter()
the incoming function is applied to each element in turn, and then the element is retained or discarded according to the return True
value False
.
The sorted() function can sort the list. In addition, the sorted()
function is also a higher-order function. It can also receive a key
function to implement custom sorting, such as sorting by absolute value size.