Cypher Head Function

head() returns the first element in a list.

Syntax: head(list)

Returns: The type of the value returned will be that of the first element of list.

Arguments

NameDescription
listAn expression that returns a list.

Example

RETURN head([4, 3, 7, null, 2])

The value returned will be the first element among all the expressions in the list passed to the function, which in this case will be 4.

Considerations

  • head(null) returns null.
  • If the first element in list is nullhead(list) will return null.
  • head([]) returns null.

Example

RETURN head([2, null, "Hello, World!", true, -1, 2020])

Returns the following Result

head([2, null, "Hello, World!", true, -1, 2020])
2

Example

RETURN head(["Hello, World!", true, -1, 2020, 2])

Returns the following Result

head(["Hello, World!", true, -1, 2020, 2])
"Hello, World!"

Example

RETURN head([true, -1, 2020, 2, "Hello, World!"])

Returns the following Result

head([true, -1, 2020, 2, "Hello, World!"])
true

Example

RETURN head([null, true, -1, 2020, 2, "Hello, World!"])

Returns the following Result

head([null, true, -1, 2020, 2, "Hello, World!"])
null

Example

RETURN head(["Hello, World!"])

Returns the following Result

head(["Hello, World!"])
"Hello, World!"

Example

WITH [true, "Hi", null, 7, 17, false, 2020] as list
RETURN head(list)

Returns the following Result

head(list)
true

Example

WITH [false] as list
RETURN head(list)

Returns the following Result

head(list)
false

Example

RETURN head([])

Returns the following Result

head([])
null

Example

WITH [] as list
RETURN head(list)

Returns the following Result

head(list)
null

Example

RETURN head(null)

Returns the following Result

head(null)
null

Learn More