Created
December 14, 2010 13:26
-
-
Save fumokmm/740404 to your computer and use it in GitHub Desktop.
Groovyでリスト内包表記
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
// 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