I have a cypher list say slots=[1,2,3,4]. How can I do something like this:
slots[0] +=1 so that slot[0] would now be increased by 1. I couldn't find a SET command or an APOC that would allow this.
A simple list comprehension will do. Using index from 0 to 3, add one to the item if it is first element (index 0), else copy the value of the item in the list
WITH [1,2,3,4] as slots
RETURN [ i IN range(0, size(slots)-1) |
case when i=0 then slots[i]+1 else slots[i] end ]
Result:
[2, 2, 3, 4]
0
Graphileon
On
You can use REDUCE() for this
WITH [1,2,3,4] as myList
RETURN REDUCE(list=[], i IN myList | list + [i + 1])
A simple list comprehension will do. Using index from 0 to 3, add one to the item if it is first element (index 0), else copy the value of the item in the list
Result: