19 lines
378 B
Python
19 lines
378 B
Python
def find_one(func, array):
|
|
'''
|
|
Utility function
|
|
|
|
Return the first element in array for which func returns True.
|
|
'''
|
|
for e in array:
|
|
if func(e):
|
|
return e
|
|
return None
|
|
|
|
def find_all(func, array):
|
|
'''
|
|
Utility function
|
|
|
|
Return all elements in array for which func returns True.
|
|
'''
|
|
return [e for e in array if func(e)]
|