Update u2/list_ops.py
This commit is contained in:
parent
8f70c5255c
commit
53f8c34cc1
@ -26,10 +26,16 @@ def length(l):
|
||||
return result
|
||||
|
||||
def map(function, list):
|
||||
|
||||
result = []
|
||||
for item in list
|
||||
result += [function(item)]
|
||||
return result
|
||||
|
||||
def foldl(function, list, initial):
|
||||
|
||||
acc = initial
|
||||
for item in list:
|
||||
acc = function(acc, item)
|
||||
return acc
|
||||
|
||||
def foldr(function, list, initial):
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user