groovy/groovy-core — pull request #40 by timyates (2012-04-10 15:51:12+00:00)
Title: GROOVY-5403 Add grep to Iterator, to return a new filtered Iterator

grep currently works on collections, but it would be nice to have it work on Iterators

We could then do lazy things like:

```
// Set our initial value
def a = 1
// Define an iterator around this value
def iter = [ hasNext:{ true }, next:{ a++ } ] as Iterator

// Define a new iterator that will just emit odd numbers
def oddIter = iter.grep { it % 2 }

// Check it's working
assert [ 1, 3, 5 ] == oddIter.take( 3 ).collect()
```