[
https://issues.apache.org/jira/browse/TINKERPOP-1849?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16723174#comment-16723174
]
ASF GitHub Bot commented on TINKERPOP-1849:
-------------------------------------------
asfgit closed pull request #1011: TINKERPOP-1849 Provide a way to fold() with
an index
URL: https://github.com/apache/tinkerpop/pull/1011
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Provide a way to fold() with an index
> -------------------------------------
>
> Key: TINKERPOP-1849
> URL: https://issues.apache.org/jira/browse/TINKERPOP-1849
> Project: TinkerPop
> Issue Type: Improvement
> Components: process
> Affects Versions: 3.3.0
> Reporter: stephen mallette
> Assignee: Daniel Kuppitz
> Priority: Major
>
> In Groovy you can call {{withIndex()}} to generate output like this:
> {code}
> gremlin> g.V().fold().next().withIndex()
> ==>[v[1],0]
> ==>[v[2],1]
> ==>[v[3],2]
> ==>[v[4],3]
> ==>[v[5],4]
> ==>[v[6],5]
> {code}
> We can currently simulate this with Gremlin via:
> {code}
> gremlin>
> g.V().project("a","b").by().by(select("x").count(local)).store("x").map(union(select('a'),
> select('b')).fold()).fold().next()
> ==>[v[1],0]
> ==>[v[2],1]
> ==>[v[3],2]
> ==>[v[4],3]
> ==>[v[5],4]
> ==>[v[6],5]
> {code}
> but it's not easy to follow, efficient, or potentially foolproof. Perhaps we
> can add an option to {{fold()}} that would take an enum of "fold operators".
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)