Remove redundant map
This commit is contained in:
@ -5,11 +5,11 @@ tags: list,function,intermediate
|
||||
|
||||
Returns `False` if the provided function returns `True` for at least one element in the list, `True` otherwise.
|
||||
|
||||
Use `all()` in combination with `map()` and `fn` to check if `fn` returns `False` for all the elements in the list.
|
||||
Use `all()` and run `fn` to check if `fn` returns `False` for all the elements in the list.
|
||||
|
||||
```py
|
||||
def none(lst, fn=lambda x: x):
|
||||
return all(map(lambda x: not fn(x), lst))
|
||||
return all(not fn(x) for x in lst)
|
||||
```
|
||||
|
||||
```py
|
||||
|
||||
Reference in New Issue
Block a user