RDF lists can be represented with the RDF.List structure.

An existing RDF.List in a given graph can be created with or its alias RDF.list, passing it the head node of a list and the graph containing the statements constituting the list.

graph =
       |> RDF.first(1)
    |> Graph.add(
       |> RDF.first(2)

list =<Foo>, graph)

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

An entirely new RDF.List can be created with RDF.List.from or RDF.list and a native Elixir list or an Elixir Enumerable with values of all types that are allowed for objects of statements (including nested lists).

list = RDF.list(["foo",, ~B<bar>, [1, 2, 3]])

If you want to add the graph statements to an existing graph, you can do that via the graph option.

existing_graph ={EX.S, EX.p, EX.O})
RDF.list([1, 2, 3], graph: existing_graph)

The head option also allows to specify a custom node for the head of the list.

The function RDF.List.values/1 allows to get the values of a RDF list (including nested lists) as a native Elixir list.

iex> RDF.list(["foo", EX.Bar, ~B<bar>, [1, 2]]) |> RDF.List.values
[~L"foo", ~I<>, ~B<bar>,
 [%RDF.Literal{value: 1, datatype: ~I<>},
  %RDF.Literal{value: 2, datatype: ~I<>}]]