Python(map,reduce,filter,sorted) function

map()The function receives two parameters, one is the function, and the other is Iterable, mapthe incoming function is applied to each element of the sequence in turn, and the result is Iteratorreturned as a new one.

reduceApply a function to a sequence [x1, x2, x3, ...], the function must accept two arguments, and reducethe 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 Truevalue False.

The sorted() function can sort the list. In addition, the sorted()function is also a higher-order function. It can also receive a keyfunction to implement custom sorting, such as sorting by absolute value size.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324726763&siteId=291194637