1. 程式人生 > >map和reduce

map和reduce

#map(f,list)
def normalize(x,):

    return x*10


list=[1,2,3,4,5]

print map(normalize,list)

 

#reduce(f,list)

def normalize(x,y):

    return x*10+y


list=[1,2,3,4,5]

print reduce(normalize,list)