在(i等){...}样式的经典中,我想迭代一个有序集合 - 伪代码:
for n,i in nodes
set node.weight = i + 1
end
可行?
答案 0 :(得分:4)
是的,但不是最漂亮的事情:
MATCH ...
WITH COLLECT(something) AS nodes
FOREACH(i IN RANGE(0, LENGTH(nodes)) |
FOREACH(node IN [nodes[i]] |
SET node.weight = i + 1
))