# 기존 함수

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))



+ Recent posts