24
Suppose that I have the following Turtle declaration:
@prefix : <http://example.org#> .
:ls :list (:a :b :c)
Is there a way to get the positions of the elements in the collection?
For example, with this query:
PREFIX : <http://example.org#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?elem WHERE {
?x :list ?ls .
?ls rdf:rest*/rdf:first ?elem .
}
I get:
--------
| elem |
========
| :a |
| :b |
| :c |
--------
But I would like a query to obtain:
--------------
| elem | pos |
==============
| :a | 0 |
| :b | 1 |
| :c | 2 |
--------------
Is it possible?