Skip to content

Instantly share code, notes, and snippets.

@rubberduck203
Created September 1, 2017 15:14
Show Gist options
  • Save rubberduck203/cea614a57e61922d92fc6d9a170abbed to your computer and use it in GitHub Desktop.
Save rubberduck203/cea614a57e61922d92fc6d9a170abbed to your computer and use it in GitHub Desktop.
def map = { collection, f ->
def result = []
collection.each { element ->
result.add(f(element))
}
result
}
def reduce = { collection, accumulator, f ->
def result = accumulator
collection.each { element ->
result = f(result, element)
}
result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment