JANINE/janine/utils.py

19 lines
378 B
Python
Raw Normal View History

2020-08-22 13:09:59 +00:00
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)]