apoc.coll.zip

Details

Syntax

apoc.coll.zip(list1, list2)

Description

Returns the two given LIST<ANY> values zipped together as a LIST<LIST<ANY>>.

Arguments

Name

Type

Description

list1

LIST<ANY>

The list to zip together with list2.

list2

LIST<ANY>

The list to zip together with list1.

Returns

LIST<ANY>

Usage examples

The following combines two lists, element for element, into a list of lists using both APOC and Cypher:

apoc.coll.zip
WITH [1, 2, 3] AS list1, ["a", "b", "c"] AS list2
RETURN apoc.coll.zip(list1, list2) as output
Using Cypher’s UNWIND and COLLECT
WITH [1, 2, 3] AS list1, ["a", "b", "c"] AS list2
RETURN COLLECT {
    UNWIND range(0, size(list1)-1) AS i
    RETURN [list1[i], list2[i]]
} AS result
Results
Output

[[1, "a"], [2, "b"], [3, "c"]]