How to get the first value of multiple arrays and store it in another array in neo4j?

112 Views Asked by At

I do have values like

first  = [1, 2]
second = [2, 3]
third  = [1, 3]

and I want to have [1,2,1] in neo4j?

1

There are 1 best solutions below

0
On

Try this:

WITH [1,2] AS first, [2,3] AS second, [1,3] AS third
RETURN [first[0]] + [second[0]] + [third[0]]

As a more generic/more elegant solution, you can also use a list comprehension:

WITH [1,2] AS first, [2,3] AS second, [1,3] AS third
RETURN [list IN [first, second, third] | list[0]]