Skip to content

Instantly share code, notes, and snippets.

@fumokmm
Created December 14, 2010 13:26
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 fumokmm/740404 to your computer and use it in GitHub Desktop.
Save fumokmm/740404 to your computer and use it in GitHub Desktop.
Groovyでリスト内包表記
// Groovyでリスト内包表記
// see: http://en.wikipedia.org/wiki/List_comprehensions
def listComprehension(list, filter, expr) {
list.findAll(filter).collect(expr)
}
println listComprehension(
(0..10).toList(),
{it % 2 == 0},
{"<${it * 3}>"}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment