Question: Anything that can be done with modifiers can also be done with pure functions. For this question, you are given three modifier functions f1 ,
Anything that can be done with modifiers can also be done with pure functions.
For this question, you are given three modifier functions f1, f2, f3 and three pure functions g1, g2, g3. Try to match each modifier function with a pure function that provides essentially the same functionality.
def f1(lst): del lst[-1] return lst def f2(lst): for e in lst.copy(): lst.append(e) return lst def f3(lst): for idx in range(len(lst)): if lst[idx] < 0: del lst[idx] return lst def g1(lst): return lst + lst def g2(lst): return [i for i in lst if i >= 0] def g3(lst): return lst[:-1]
f1
[ Choose ] g2 g1 g3
f2
[ Choose ] g2 g1 g3
f3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
