Logo

Programming-Idioms

History of Idiom 57 > diff from v56 to v57

Edit summary for version 57 by andyjduncan:
New Groovy implementation by user [andyjduncan]

Version 56

2020-05-10, 21:47:49

Version 57

2020-10-10, 11:24:45

Idiom #57 Filter list

Create list y containing items from list x satisfying predicate p. Respect original ordering. Don't modify x in-place.

Idiom #57 Filter list

Create list y containing items from list x satisfying predicate p. Respect original ordering. Don't modify x in-place.

Variables
y,x,p
Variables
y,x,p
Extra Keywords
satisfy
Extra Keywords
satisfy
Code
def y = x.findAll(p)
Comments bubble
Simple predicates are typically implemented as closures on the implicit argument it.
Doc URL
https://docs.groovy-lang.org/latest/html/groovy-jdk/java/util/List.html#findAll(groovy.lang.Closure)
Demo URL
https://groovyconsole.appspot.com/script/5112998502858752