reduce() : function for python

xiaoxiao2021-02-28  4

1、reduce()

     general form:  reduce(f(), list[], int);

     A.  f() must has two parameter。eg:

             f(x+y): x+y;

             f(x*y): x*y;

     B.   list[] take the parameter

     C.  int is not necessary.  it is the beginer for f().

def f(x, y ):

     redurn x + y

reduce (f, [1,2,3,4,5], 100 or null)

 

转载请注明原文地址: https://www.6miu.com/read-2450082.html

最新回复(0)