-
-
Save anonymous/d713769fac5c77301fec7efd63dfbc7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lazy | |
def filter_elements(elements, x, limit) | |
elements | |
.lazy | |
.map {|e| Result.new(e, x)} | |
.select {|new_e| new_e.work < 100 } | |
.sort_by {|new_e| new_e.work } | |
.take(limit) | |
.to_a | |
end | |
# non lazy | |
def filter_elements(elements, x, limit) | |
elements | |
.map {|e| Result.new(e, x)} | |
.select {|new_e| new_e.work < 100 } | |
.sort_by {|new_e| new_e.work } | |
.take(limit) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment