File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+ from setuptools import reduce #importing reduce module for using reduce function
3
+
4
+ l1 = [2 ,3 ,4 ,5 ,6 ]
5
+
6
+ mapping_the_l1 = list (map (lambda x : x * 2 , l1 )) # MAP FUNCTION APPLIES THE GIVEN COMMAND TO EVERY INDEX OF A LIST
7
+ # IN THIS CASE WE ARE MULTIPLYING EVERY CHARACTER IF LIST l1 TO 2 USING LAMBDA FUNCTION
8
+
9
+ print (mapping_the_l1 )
10
+
11
+
12
+ filtering_the_l1 = list (filter (lambda x : x % 2 == 0 )) #FILTER FUNCTION FILTERS THE LIST ACCORDING TO OUR WISH
13
+ # IN THIS CASE WE ARE FILERING THE NUMBER WHICH IS DIVISIBLE BY 2 IN l1.
14
+
15
+ print (filtering_the_l1 )
16
+
17
+ def add (x , y ):
18
+ return x + y
19
+
20
+ reducing_the_l1 = reduce (add , l1 ) # REDUCE FUNCTION IS USED FOR DOING MATHEMATICAL OPERATIONS IN A LIST
21
+ # HERE, WE ARE ADDING ALL THE CHARACTERS THE LIST l1
22
+
23
+ print (reducing_the_l1 )
You can’t perform that action at this time.
0 commit comments