[ https://issues.apache.org/jira/browse/GROOVY-10473?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17489084#comment-17489084 ]
Eric Milles commented on GROOVY-10473: -------------------------------------- I also ran into the missing head/tail problem: https://stackoverflow.com/questions/19803058/java-8-stream-getting-head-and-tail I went with: {code:groovy} stream.iterator().with { if (hasNext()) { def head = next() forEachRemaining(/* tail consumer */) } } {code} Not sure if there is an opportunity to generalize this... > Extend streams support to spread and subscript > ---------------------------------------------- > > Key: GROOVY-10473 > URL: https://issues.apache.org/jira/browse/GROOVY-10473 > Project: Groovy > Issue Type: Improvement > Reporter: Eric Milles > Priority: Major > > Groovy 3 and 4 added some {{Stream}} extension methods like {{plus}}, > {{toList}} and {{toArray}}. And some default type conversions like > {{String[] array = stream;}}. This could be taken further by having > spread-dot and subscript support: > {code:groovy} > stream*.thing // --> stream.map(it -> it.thing).toList() > stream[1] // --> stream.skip(1).findFirst().orElse(null) > stream[1..10] // --> stream.skip(1).limit(10-1).toList() > // consider negative indexes and reverse ranges > {code} > Also, {{forEachPair}} and {{zip}} extension methods would be useful for > processing parallel streams. -- This message was sent by Atlassian Jira (v8.20.1#820001)