1
구조체를 반환하는 것처럼 보이지만 값은 존재하지 않습니다 ...Groovy에서 데이터베이스 쿼리로 트리를 만드는 법?
g = TinkerGraphFactory.createTinkerGraph()
root = g.v(1)
def tree
def results = []
tree = { vertices ->
vertices.each() {
children = it.out().toList()
if (children)
results << tree(children)
}
results.toList()
}
println tree(root)
결과는 다음과 같습니다.
$ ./gremlin.sh -e treeTest.groovy
[[], [[]]]
참고 : 일반적으로 Python에서는 Groovy가 아닌 나는 아마 명백한 무엇인가 놓치고있다.