-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLambda Function Exp.py
More file actions
69 lines (60 loc) · 1.99 KB
/
Lambda Function Exp.py
File metadata and controls
69 lines (60 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# LAMBDA functions are 'nameless', 'anonymous' functions.
# They are still very new to me, but at least we can cheat. lol
# HIGHLIGHT AND COPY CODE, THEN PASTE INTO YOUR PREFERABLE PYTHON APP/IDLE
def num(x):
return x**3
print(num(10))
num=lambda x:x**3
print(num(10))
'''----------------------------------------------------------------'''
def num(x):
return lambda x:x**3
c=num(3)
print(c(10))
'''----------------------------------------------------------------'''
mylist=[1,2,3,4,5,6]
newlist=list(filter(lambda a:(a/3==2),mylist))
print(newlist)
'''----------------------------------------------------------------'''
mylist=[1,2,3,4,5,6]
p=list(map(lambda a:(a/3!=2),mylist))
print(p)
'''----------------------------------------------------------------'''
from functools import reduce
r=reduce(lambda a,b:a+b,[23,56,43,98,1])
print(r)
'''----------------------------------------------------------------'''
s=lambda a: a*a
print(s(4))
'''----------------------------------------------------------------'''
d=lambda x,y:3*x+4*y
print(d(4,7))
'''----------------------------------------------------------------'''
x=lambda a,b:(a+b)**2
print(x(3,4))
'''----------------------------------------------------------------'''
x=lambda a:a+10
print(x(5))
'''----------------------------------------------------------------'''
x=lambda a,b:a*b
print(x(5,6))
'''----------------------------------------------------------------'''
x=lambda a,b,c:a+b+c
print(x(5,6,2))
'''----------------------------------------------------------------'''
def myfunc(n):
return lambda a:a*n
mydoubler=myfunc(2)
print(mydoubler(11))
'''----------------------------------------------------------------'''
def myfunc(n):
return lambda a:a*n
mytripler=myfunc(3)
print(mytripler(11))
'''----------------------------------------------------------------'''
def myfunc(n):
return lambda a:a*n
mydoubler=myfunc(2)
mytripler=myfunc(3)
print(mydoubler(11))
print(mytripler(11))