Re: Example how to count in N3

Hi Patrick

Try list:iterate <http://eulersharp.sourceforge.net/2003/03swap/eye-builtins.html>. See http://ppr.cs.dal.ca:3002/n3/editor/s/2rJmxYti <http://ppr.cs.dal.ca:3002/n3/editor/s/2rJmxYti> for an example.

(This is a new builtin introduced by the community group and supported by eye and jen3.)


W

> On Jul 22, 2022, at 9:49 AM, 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# <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:54:30 UTC