# `RDF.List`
[🔗](https://github.com/rdf-elixir/rdf-ex/blob/v3.0.0/lib/rdf/model/list.ex#L1)

A structure for RDF lists.

see
- <https://www.w3.org/TR/rdf-schema/#ch_collectionvocab>
- <https://www.w3.org/TR/rdf11-mt/#rdf-collections>

# `t`

```elixir
@type t() :: %RDF.List{graph: RDF.Graph.t(), head: RDF.IRI.t()}
```

# `empty?`

```elixir
@spec empty?(t()) :: boolean()
```

Checks if a list is the empty list.

# `from`

```elixir
@spec from(
  Enumerable.t(),
  keyword()
) :: t()
```

Creates a `RDF.List` from a native Elixir list or any other `Enumerable` with coercible RDF values.

By default, the statements constituting the `Enumerable` are added to an empty graph. An
already existing graph to which the statements are added can be specified with
the `graph` option.

The name of the head node can be specified with the `head` option
(default: `RDF.bnode()`, i.e. an arbitrary unique name).
Note: When the given `Enumerable` is empty, the `name` option will be ignored -
the head node of the empty list is always `RDF.nil`.

# `new`

```elixir
@spec new(RDF.Resource.coercible(), RDF.Graph.t()) :: t() | nil
```

Creates a `RDF.List` for a given RDF list node of a given `RDF.Graph`.

If the given node does not refer to a well-formed list in the graph, `nil` is
returned. A well-formed list

- consists of list nodes which have exactly one `rdf:first` and `rdf:rest`
  statement each
- does not contain cycles, i.e. `rdf:rest` statements don't refer to
  preceding list nodes

# `node?`

Checks if the given `RDF.Description` describes an RDF list node.

# `node?`

```elixir
@spec node?(any(), RDF.Graph.t()) :: boolean()
```

Checks if a given resource is an RDF list node in a given `RDF.Graph`.

Although, technically a resource is a list, if it uses at least one `rdf:first`
or `rdf:rest`, we pragmatically require the usage of both.

Note: This function doesn't indicate if the list is valid.
See `new/2` and `valid?/2` for validations.

# `nodes`

```elixir
@spec nodes(t()) :: [RDF.BlankNode.t()]
```

The RDF nodes constituting a `RDF.List` as an Elixir list.

# `prepend`

```elixir
@spec prepend(t(), any(), keyword()) :: t()
```

Prepends a value to a `RDF.List`.

The name of the head node can be specified with the `head` option
(default: `RDF.bnode()`, i.e. an arbitrary unique name).

# `valid?`

```elixir
@spec valid?(t()) :: boolean()
```

Checks if the given list consists of list nodes which are all blank nodes.

# `values`

```elixir
@spec values(t()) :: Enumerable.t()
```

The values of a `RDF.List` as an Elixir list.

Nested lists are converted recursively.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
