Skip to content

Commit

Permalink
Increase performance of Function
Browse files Browse the repository at this point in the history
3 Times Faster Response
  • Loading branch information
Miladkhoshdel authored Nov 18, 2021
1 parent 34871c5 commit 02d451d
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions algorithms/arrays/limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@

# tl:dr -- array slicing by value
def limit(arr, min_lim=None, max_lim=None):
min_check = lambda val: True if min_lim is None else (min_lim <= val)
max_check = lambda val: True if max_lim is None else (val <= max_lim)

return [val for val in arr if min_check(val) and max_check(val)]
return list(filter(lambda x: (min_lim <= x <= max_lim), arr))

0 comments on commit 02d451d

Please sign in to comment.