Paul King created GROOVY-11596: ---------------------------------- Summary: Additional DGM lazy iterator methods Key: GROOVY-11596 URL: https://issues.apache.org/jira/browse/GROOVY-11596 Project: Groovy Issue Type: Improvement Reporter: Paul King Assignee: Paul King
This issue is to provide a few more iterator variants in the DGM methods. Some of these methods already exist but have an eager implementation. Others are inspired from [groovy-stream|https://timyates.github.io/groovy-stream/]. Instead of being executing in multiple seconds, as is, the following code executes in a few 10s of ms with the iterator line uncommented, and creates much fewer intermediate collections. {code:groovy} assert (1..10000) // .iterator() .repeat(10000) .take(20000000) .takeWhile{ true } .drop(5) .collate(2) .flatten{ it * 2 } .dropRight(1) .dropWhile{ it < 15 } .withIndex() .init() .take(5) .injectAll([0, 0]){ a, b -> [a.first() + b.first(), a.last() + b.last()] } .collect() .toString() == '[[16, 0], [34, 1], [54, 3], [76, 6], [100, 10]]' {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)