All list ops complete
This commit is contained in:
parent
81ac85ee6f
commit
321760e149
@ -4,5 +4,48 @@ for gns in list1:
|
|||||||
pusti.append(gns)
|
pusti.append(gns)
|
||||||
for exc in list2:
|
for exc in list2:
|
||||||
pusti.append(exc)
|
pusti.append(exc)
|
||||||
|
|
||||||
return pusti
|
return pusti
|
||||||
|
|
||||||
|
def concat(list):
|
||||||
|
pusti = []
|
||||||
|
for gns in list:
|
||||||
|
pusti.extend(gns)
|
||||||
|
return pusti
|
||||||
|
|
||||||
|
def filter(function, list):
|
||||||
|
pusti = []
|
||||||
|
for gns in list:
|
||||||
|
if function(gns):
|
||||||
|
pusti.append(gns)
|
||||||
|
return pusti
|
||||||
|
|
||||||
|
def length(list):
|
||||||
|
pocatok = 0
|
||||||
|
for gns in list:
|
||||||
|
pocatok = pocatok + 1
|
||||||
|
return pocatok
|
||||||
|
|
||||||
|
def map(function, list):
|
||||||
|
pusti = []
|
||||||
|
for gns in list:
|
||||||
|
function(gns)
|
||||||
|
pusti.append(function(gns))
|
||||||
|
return pusti
|
||||||
|
|
||||||
|
def foldl(function, accumulator, initial):
|
||||||
|
accumulator = initial
|
||||||
|
for gns in list:
|
||||||
|
accumulator = function(accumulator, gns)
|
||||||
|
return accumulator
|
||||||
|
|
||||||
|
def foldr(function, initial, acc):
|
||||||
|
acc = initial
|
||||||
|
for gns in list[::-1]:
|
||||||
|
acc = function(gns, acc)
|
||||||
|
return acc
|
||||||
|
|
||||||
|
def reverse(list):
|
||||||
|
pusti = []
|
||||||
|
for gns in list:
|
||||||
|
pusti.append(gns)
|
||||||
|
return pusti[::-1]
|
||||||
@ -4,5 +4,48 @@ for gns in list1:
|
|||||||
pusti.append(gns)
|
pusti.append(gns)
|
||||||
for exc in list2:
|
for exc in list2:
|
||||||
pusti.append(exc)
|
pusti.append(exc)
|
||||||
|
|
||||||
return pusti
|
return pusti
|
||||||
|
|
||||||
|
def concat(list):
|
||||||
|
pusti = []
|
||||||
|
for gns in list:
|
||||||
|
pusti.extend(gns)
|
||||||
|
return pusti
|
||||||
|
|
||||||
|
def filter(function, list):
|
||||||
|
pusti = []
|
||||||
|
for gns in list:
|
||||||
|
if function(gns):
|
||||||
|
pusti.append(gns)
|
||||||
|
return pusti
|
||||||
|
|
||||||
|
def length(list):
|
||||||
|
pocatok = 0
|
||||||
|
for gns in list:
|
||||||
|
pocatok = pocatok + 1
|
||||||
|
return pocatok
|
||||||
|
|
||||||
|
def map(function, list):
|
||||||
|
pusti = []
|
||||||
|
for gns in list:
|
||||||
|
function(gns)
|
||||||
|
pusti.append(function(gns))
|
||||||
|
return pusti
|
||||||
|
|
||||||
|
def foldl(function, accumulator, initial):
|
||||||
|
accumulator = initial
|
||||||
|
for gns in list:
|
||||||
|
accumulator = function(accumulator, gns)
|
||||||
|
return accumulator
|
||||||
|
|
||||||
|
def foldr(function, initial, acc):
|
||||||
|
acc = initial
|
||||||
|
for gns in list[::-1]:
|
||||||
|
acc = function(gns, acc)
|
||||||
|
return acc
|
||||||
|
|
||||||
|
def reverse(list):
|
||||||
|
pusti = []
|
||||||
|
for gns in list:
|
||||||
|
pusti.append(gns)
|
||||||
|
return pusti[::-1]
|
||||||
Loading…
Reference in New Issue
Block a user