Lambda Function(람다 함수)은 함수를 메모리에 할당하지 않고, 한 줄로 간단하게 정의할 수 있는 이름 없는 anonymous 함수이다.
lambda <arguments>: <expression># def
def f(x):
return x**2
# lambda
lambda x: x**2
# def
def add(a, b):
return a + b
# lambda
lambda a, b: a + b
filter는 특정한 조건에서 참이 되는 요소를 반환하는 함수이다.
filter(function, iterable)
function: 함수nums = [1, 2, 3, 4]
even_nums = list(filter(lambda x: x % 2 == 0, nums))
map은 함수를 각각의 item에 적용하는 함수이다.
map(function, iterable)
function: 함수nums = [1, 2, 3, 4]
square_nums = list(map(lambda x: x**2, nums))
reduce는 sequence에 누적 연산을 적용하여 하나의 값으로 줄이는 함수이다.
reduce(function, iterable)
function: 함수