// condition #1: age >= 29// condition #2: age <= 29g = TinkerFactory.createModern()//// OR (union)//gremlin> g.V().union(__.has("age", lte, 29), __.has("age", gte, 29)).dedup()==>marko 29
==>vadas 27
==>josh 32
==>peter 35
//// AND (intersect)//gremlin> g.V().has(label, "person").union(__.has("age", lte, 29).store("x"),__.has("age", gte, 29).store("y")).retain("x").retain("y").dedup()
==>marko 29
//// XOR (difference)//gremlin> g.V().has(label, "person").union(__.has("age", lte, 29).store("x"),__.has("age", gte, 29).store("y")).fold().unfold().union(__.except("x"),__.except("y"))==>vadas 27
==>josh 32
==>peter 35
//// XOR (alternative using choose())//gremlin> g.V().has(label, "person").choose { it.value("age").compareTo(29) /* <- that's actually cheated */ }.fork(-1, __.store("x")).fork( 0, __.store("x").store("y")).fork( 1, __.store("y")).fold().unfold().union(__.except("x"), __.except("y"))==>vadas 27
==>josh 32
==>peter 35* I extended each traversal by .map { it.get().value("name").padRight(6) + it.get().value("age") } to get more meaningful results.Cheers,
Daniel
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/DA37217A-F029-4CBA-A7BC-99DC5A8BA3FD%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
[snip]
I don't like the name fork(), but now you no longer have to create that lame 'ol Map<M,Traversal> which is ugly in Java… Now you can just choose().fork().fork().fork(). Likewise for branch() and union(), though because union() is a fork on Pick.any, the var args union(traversal…) remains. Again, Daniel and I couldn't come up with a better name for fork(), so if someone has an idea, bust it out.
[snip]
--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/f99b69c5-3097-45ab-b76b-10c9a0de1ed3%40googlegroups.com.
Hi Matt,We just changed it to option().branch().option().option().option()choose().option().option().option()The problem with "choice" is that is seems too tied to choose()-step.What do you think of option()?