Skip to content

Commit 106a6b9

Browse files
committed
python
1 parent a978f35 commit 106a6b9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

day33(Lambdafun).py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#LAMBDA is anonymous function
12
# def double(x):
23
# return x*2
34
double=lambda x:x*2
@@ -14,3 +15,5 @@
1415
def appl(fx,value):
1516
return 6 +fx(value)
1617
print(appl(cube,2))
18+
print(appl(lambda x:x*x*x,2))
19+
print(appl(lambda x:x*x,2))

day34(Map filter ).py

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
# for item in l:
1010
# newl.append(cube(item))
1111
# newl=list(map(cube,l)) # this is why map is used
12-
newl=list(map(lambda x:x*x*x,l)) # this is why map is used
12+
newl=list(map(lambda x:x*x*x,l)) # this is why lambda map is used
1313
print(newl)
1414

1515
#FILTER higher order function
1616

1717
def filter_fun(a):
1818
return a>2
19-
newnewl= list(filter(filter_fun,l))
19+
newnewl= list(filter(filter_fun,l)) #returns boolean
2020
print(newnewl)
2121

2222

0 commit comments

Comments
 (0)