If I add a generator as the object of my chain and I use the take_while function, it tries to call the nth index of the generator which is not supported.
A suggesteion for this would be
def take_while(array, predicate=None):
array = list(array)
n = 0
for is_true, _, _, _ in iteriteratee(array, predicate):
if is_true:
n += 1
else:
break
return array[:n]
or
def take_while(array, predicate=None):
new_array = []
while True:
is_true, n, _, _ in iteriteratee(array, predicate):
if not is_true:
break
new_array.append(array[n])
return new_array
If I add a generator as the object of my chain and I use the
take_while
function, it tries to call the nth index of the generator which is not supported.A suggesteion for this would be
or