Re: Example how to count in N3

I'm thinking list builtin list:length?
http://eulersharp.sourceforge.net/2003/03swap/eye-builtins.html
[image: image.png]

On Fri, Jul 22, 2022 at 2:21 PM Patrick Hochstenbach <
Patrick.Hochstenbach@ugent.be> wrote:

> 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:53:44 UTC