Work on big refactor

This commit is contained in:
2018-10-13 23:01:45 +03:00
parent ae77251883
commit 1d5c7ea24b
447 changed files with 67198 additions and 1226 deletions

View File

@ -0,0 +1,12 @@
def first_true(*args, default=False, pred=None):
"""Returns the first true value in the iterable.
If no true value is found, returns *default*
If *pred* is not None, returns the first item
for which pred(item) is true.
"""
# first_true([a,b,c], x) --> a or b or c or x
# first_true([a,b], x, f) --> a if f(a) else b if f(b) else x
return next(filter(pred, args), default)