graph icon indicating copy to clipboard operation
graph copied to clipboard

Add an example that shows how to select all but the last item in a collection/stream

Open krlawrence opened this issue 4 years ago • 0 comments

There is no list separator type syntax in Gremlin. This is one way to achieve the [0:-2] type pattern.

gremlin> g.V(1,2,3,4).fold().sideEffect(tail(local).store('t')).unfold().where(neq('t')).by().by(unfold())
==>v[1]
==>v[2]
==>v[3]  

Also add an example that shows how to pick the penultimate value is a stream such as

gremlin> g.V(1,2,3,4).tail(2).limit(1)
==>v[3]     

krlawrence avatar Mar 17 '21 15:03 krlawrence