Skip to content

Commit 0d384f3

Browse files
a bit more cleanup
1 parent 35e1459 commit 0d384f3

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

modules/ROOT/pages/expressions/list-expressions.adoc

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ RETURN [1,2] || [3,4] AS list1,
5555
2+d|Rows: 1
5656
|===
5757

58-
.Concatenating two `LIST` properties
58+
.Concatenate two `LIST` properties
5959
[source, cypher]
6060
----
6161
MATCH (cecil:Person {name: 'Cecil'}), (cecilia:Person {name: 'Cecilia'})
@@ -75,7 +75,7 @@ RETURN cecil.skills || cecilia.skills AS combinedSkills
7575
The `+` operator can add elements to the beginning or end of a `LIST` value.
7676
This is not possible using the `||` operator.
7777

78-
.Adding elements to the beginning of a `LIST`
78+
.Add elements to the beginning and end of a `LIST`
7979
[source, cypher]
8080
----
8181
WITH [1, 2, 3, 4] AS list
@@ -94,7 +94,7 @@ RETURN 0 + list AS newBeginning,
9494
2+d|Rows: 1
9595
|===
9696

97-
.Adding elements to the beginning of a `LIST` property `+`
97+
.Add elements to the beginning of a `LIST` property
9898
[source, cypher]
9999
----
100100
MATCH (cecil:Person {name: 'Cecil'})
@@ -114,7 +114,7 @@ RETURN cecil.skills AS skillsList
114114

115115
If `NULL` is part of a concatenated `LIST`, `NULL` will be a part of the new `LIST`.
116116

117-
.Concatenating `LIST` including `NULL`
117+
.Concatenate `LIST` including `NULL`
118118
[source, cypher]
119119
----
120120
RETURN [1, 2] || [3, null] AS listWithNull
@@ -139,7 +139,7 @@ The subscript operator, `[]`, can be used to access specific elements in a `LIST
139139
`[0]` refers to the first element in a `LIST`, `[1]` to the second, and so on.
140140
`[-1]` refers to the last element in a `LIST`, `[-2]` to the penultimate element, and so on.
141141

142-
.Accessing individual elements in a `LIST`
142+
.Access individual elements in a `LIST`
143143
[source, cypher]
144144
----
145145
WITH [1, 2, 3, 4] AS list
@@ -168,7 +168,7 @@ The index of the element in the `LIST` can be parameterized.
168168
}
169169
----
170170

171-
.Accessing `LIST` elements with a parameter
171+
.Access `LIST` elements with a parameter
172172
[source, cypher]
173173
----
174174
WITH [1, 2, 3, 4] AS list
@@ -185,7 +185,7 @@ RETURN list[$myIndex] AS secondElement
185185
1+d|Rows: 1
186186
|===
187187

188-
.Accessing a `LIST` within a nested `LIST`
188+
.Access a `LIST` within a nested `LIST`
189189
[source, cypher]
190190
----
191191
WITH [[1, 2], [3, 4], [5, 6]] AS nestedList
@@ -204,7 +204,7 @@ RETURN nestedList[1] AS secondList
204204

205205
The xref:expressions/predicates/list-operators.adoc[`IN`] operator, which checks for `LIST` membership, can be used together with `[]` to test whether an element exists in a nested `LIST`.
206206

207-
.Checking for membership in nested `LIST`
207+
.Check for membership in a nested `LIST`
208208
[source, cypher]
209209
----
210210
WITH [[1, 2, 3], [4, 5, 6]] AS nestedList
@@ -223,7 +223,7 @@ RETURN 3 IN nestedList[0] AS elementPresent
223223

224224
Attempting to reference an element outside the bounds of the `LIST` will return `NULL`, as will attempting to access elements from an empty `LIST`.
225225

226-
.Out-of-bounds and empty list access
226+
.Out-of-bounds and empty `LIST` access
227227
[source, cypher]
228228
----
229229
WITH [1, 2, 3, 4] AS list, [] AS emptyList
@@ -308,7 +308,7 @@ RETURN nestedList[1][0..2] AS slicedInnerList
308308

309309
Accessing specific elements or a range of elements can also be used in combination with the `+` operator to create a new `LIST` with values inserted into specific sections of an existing `LIST` value.
310310

311-
.Inserting elements into specific positions of a `LIST`
311+
.Insert elements into specific positions of a `LIST`
312312
[source, cypher]
313313
----
314314
WITH [1, 3, 4] AS list
@@ -390,7 +390,7 @@ RETURN [n IN list WHERE n > 2 | n] AS filteredList
390390

391391
This below query iterates over the `skills` property of each Person node and creates a new `LIST` by xref:expressions/string-operators.adoc[concatenating the `STRING`] `" expert"` to each element in `skills`.
392392

393-
.Modify `LIST` properties
393+
.Modify `LIST` properties using list comprehension
394394
[source, cypher]
395395
----
396396
MATCH (p:Person) WHERE p.skills IS NOT NULL
@@ -434,10 +434,9 @@ RETURN [person IN collect(p) WHERE 'Python' IN person.skills | person.name] AS p
434434
1+d|Rows: 1
435435
|===
436436

437-
438437
List comprehension can be used to remove any unknown `NULL` values when concatenating `LIST` values.
439438

440-
.Use a list comprehension to remove `NULL` values during list concatenation
439+
.List comprehension to remove `NULL` values during list concatenation
441440
[source, cypher]
442441
----
443442
RETURN [x IN ([1, null, 3] || [null, 5, null]) WHERE x IS NOT NULL] AS listWithoutNull
@@ -513,7 +512,7 @@ RETURN [(cecil)-[:WORKS_FOR]->+(superior:Person) | superior.skills] AS superiors
513512
----
514513

515514
Pattern comprehension only supports only the xref:patterns/reference.adoc#variable-length-relationships[variable-length relationships] syntax.
516-
The belowquery uses a pattern comprehension to collect the skills of all superiors in the chain above `Cecil`.
515+
The below query uses a pattern comprehension to collect the skills of all superiors in the chain above `Cecil`.
517516
The xref:functions/list.adoc#functions-reduce[`reduce()`] function concatenates these skills into a single `LIST`, and xref:clauses/unwind.adoc[`UNWIND`] is used to flatten this `LIST` before returning the distinct skills in a new `LIST`.
518517

519518
.Allowed - pattern comprehension to match patterns of a variable length using variable-length relationship syntax

0 commit comments

Comments
 (0)