Example how to count in N3

Hi all,

I need a way to count things using N3 but I don't know yet how this could be done.
E.g. as data input I have:

:Collection :parts (:part1 :part2 :part3 ...).

As output I would like to get

:part1 :order 1 .
:part2 :order 2.
:part3 :order 3.
...

I know I can loop over a list using the list:member:

@prefix list: <http://www.w3.org/2000/10/swap/list#>.

{
  ?subject :parts ?parts .
  ?parts list:member ?part .
}
=>
{
  ?part :order 1 .
}.

But I fail to find a way to add a counter for order. Any hints available?

BR

Patrick

Received on Friday, 22 July 2022 18:20:49 UTC