Last active
December 20, 2017 16:55
-
-
Save arlandism/773303a038cf72f42d7c29f155b7a1b3 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
def sum_with(list, &block) | |
result = block.call(list) | |
result.reduce(0) {|acc, n| acc += n} | |
end | |
def sum_doubles(list) | |
sum_with(list) {|n| n * 2} | |
end | |
def sum_triples(list) | |
sum_with(list) {|n| n * 3} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment