DEV Community

Indigo Norrbottenspets
Indigo Norrbottenspets

Posted on

Neo4j: List expressions

size($list)
Enter fullscreen mode Exit fullscreen mode

Number of elements in the list.

reverse($list)
Enter fullscreen mode Exit fullscreen mode

Reverse the order of the elements in the list.

head($list), last($list), tail($list)
Enter fullscreen mode Exit fullscreen mode

head() returns the first, last() the last element of the list. tail() returns all but the first element. All return null for an empty list.

[x IN list | x.prop]
Enter fullscreen mode Exit fullscreen mode

A list of the value of the expression for each element in the original list.

[x IN list WHERE x.prop <> $value]
Enter fullscreen mode Exit fullscreen mode

A filtered list of the elements where the predicate is true.

[x IN list WHERE x.prop <> $value | x.prop]
Enter fullscreen mode Exit fullscreen mode

A list comprehension that filters a list and extracts the value of the expression for each element in that list.

reduce(s = "", x IN list | s + x.prop)
Enter fullscreen mode Exit fullscreen mode

Evaluate expression for each element in the list, accumulate the results.

Useful links

Top comments (0)