-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFMR6.py
58 lines (37 loc) · 1.17 KB
/
FMR6.py
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
CheckEven = lambda No : (No % 2 == 0)
Doubles = lambda No: No * 2
Sum = lambda A, B : A + B
def filterX(Helper_Function, Data):
Result = []
for No in Data:
if (Helper_Function(No) == True):
Result.append(No)
return Result
def mapX(Helper_Function, Data):
Result = []
for No in Data:
Value = Helper_Function(No)
Result.append(Value)
return Result
def reduceX(Helper_Function, Data):
Ans = 0
for no in Data:
Ans = Helper_Function(Ans, no)
return Ans
def main():
print("Enter number of elements you want to enter : ")
iSize = int(input())
Data_Input = []
print("Please enter the data ")
for iCnt in range(0, iSize, 1):
Value = int(input())
Data_Input.append(Value)
print("Data is : ", Data_Input)
Data_Filter = filterX(CheckEven, Data_Input)
print("Data after filter is : ", Data_Filter)
Data_Map = mapX(Doubles, Data_Filter)
print("Data after map is : ", Data_Map)
Output = reduceX(Sum, Data_Map)
print("Result after reduce is : ", Output)
if __name__ == "__main__":
main()