# 기존 함수
def fx(x, y):
return x+y
print("Fuction :",fx(1,9))
print('=====================================')
# lamdba
fx2 = lambda x : x + x
print("Lambda :",fx2(7))
print('=====================================')
# map
A_list = [i for i in range(5)]
print("List :", A_list)
print("Map :",list(map(fx2, A_list)))
print('=====================================')
# list Comprehension
print("List Comprehension :",[v ** 2 for v in A_list])
print('=====================================')
# Reduce
B_list = [i for i in range(0,11)]
from functools import reduce
print("Reduce :",reduce(lambda x, y : x+y, B_list))
print('=====================================')
#sum
print("Sum :",sum(B_list))
'Study > Code' 카테고리의 다른 글
numpy를 이용해 새로운 array 만들기. (0) | 2019.02.16 |
---|---|
Python Asterisk 가변인자. *args, **kargs (0) | 2018.12.28 |
Python list Comprehension (0) | 2018.12.27 |
pickle 파일 읽기 , 저장 (0) | 2018.12.20 |
python Image resize 파이썬 이미지 크기조정 (0) | 2018.12.18 |