kangchanguk / study

0 stars 0 forks source link

python(lambda, map, filter, reduce) #1

Open kangchanguk opened 3 years ago

kangchanguk commented 3 years ago

lambda

lambda 인자: 표현식

Sample

def hap(x,y):
    return x+y

(lambda x,y:x+y)(10,20)

map()

map(lambda x: x **2, range(5))
[0, 1, 4, 9, 16, 25]

reduce()

결과 값: 10


## filter()
- filter(함수, 리스트)

list(filter(lambda x: x<5, range(10))) [0,1,2,3,4]

list(filter(lambda x:x%2, range(10)))