apoc.coll.insert
Syntax |
|
||
Description |
Inserts a value into the specified index in the |
||
Arguments |
Name |
Type |
Description |
|
|
The list to insert a value into. |
|
|
|
The position in the list to insert the given value. |
|
|
|
The value to be inserted. |
|
Returns |
|
Usage examples
The following examples insert the value 11
at index 3
in the list using both APOC and Cypher:
apoc.coll.insert
WITH [1,3,5,7,9] AS originalList, 3 AS index, 11 AS itemToInsert
RETURN apoc.coll.insert(originalList, index, itemToInsert) AS output;
Using Cypher’s list concatenation
WITH [1,3,5,7,9] AS originalList, 3 AS index, 11 AS itemToInsert
RETURN originalList[0..index] + itemToInsert + originalList[index..] AS output
Output |
---|
[1, 3, 5, 11, 7, 9] |