Skip to content

Instantly share code, notes, and snippets.

@arlandism
Last active December 20, 2017 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arlandism/773303a038cf72f42d7c29f155b7a1b3 to your computer and use it in GitHub Desktop.
Save arlandism/773303a038cf72f42d7c29f155b7a1b3 to your computer and use it in GitHub Desktop.
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