File tree 1 file changed +43
-0
lines changed
1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ def append (list1 , list2 ):
2
+ return list1 + list2
3
+
4
+
5
+ def concat (lists ):
6
+ result = []
7
+ for list in lists :
8
+ result += list
9
+ return result
10
+
11
+
12
+ def filter (function , list ):
13
+ return [x for x in list if function (x )]
14
+
15
+
16
+ def length (list ):
17
+ return len (list )
18
+
19
+
20
+ def map (function , list ):
21
+ result = []
22
+ for element in list :
23
+ result .append (function (element ))
24
+ return result
25
+
26
+
27
+ def foldl (function , list , initial ):
28
+ result = initial
29
+ for i in range (len (list )):
30
+ result = function (result , list [i ])
31
+ return result
32
+
33
+
34
+ def foldr (function , list , initial ):
35
+ if len (list ) == 0 :
36
+ return initial
37
+ result = list [0 ]
38
+ for i in range (1 , len (list )):
39
+ result = function (result , list [i ])
40
+ return result + initial
41
+
42
+ def reverse (list ):
43
+ return list [::- 1 ]
You can’t perform that action at this time.
0 commit comments