#! /Usr/bin/ENV Python #-*-coding: UTF-8-*-# functional. PY # def Foo (X, Y, * ARGs): Sum = x + yfor N in ARGs: Sum + = nreturn sum # apply, filter, MAP, cecedef main (): print Foo (,) print apply (Foo, [, 5]) # apply is used to call a function, and the function itself is also used as a parameter # filter (func, SEQ), use the function to determine whether the elements in the sequence meet the conditions. If the value is true, the listprint filter (lambda X: X % 2, [X for X in range (10)]) # map (func, seq), which is applied to each element of the sequence using a function, combine all the results into a list to return print map (lambda X: x * 2, [X for X in range (10)]) print map (lambda X, Y: X + Y, [, 5], [, 6]) print map (lambda X, Y: (x + y, x-y), [, 5], [2, 4, 6]) print map (none, [1, 3, 5], [2, 4, 6]) # reduce can be considered as reduce (func, x, y, z ...) <=> func (x, y), Z )... print reduce (lambda X, Y: X + Y, [X for X in range (10)]) print [X for X in range (10)] return 0if _ name _ = '_ main _': Main ()