- From: Jos De Roo <josderoo@gmail.com>
- Date: Fri, 22 Jul 2022 21:09:21 +0200
- To: William Van Woensel <william.vanwoensel@gmail.com>
- Cc: Patrick Hochstenbach <Patrick.Hochstenbach@ugent.be>, "public-n3-dev@w3.org" <public-n3-dev@w3.org>
- Message-ID: <CAJbsTZegesh5+-NmbrEzMYFzGCqkw4GUp86TzsSw6pTGKh1Wzg@mail.gmail.com>
Exactly! Another way that would also work with Cwm is @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. @prefix math: <http://www.w3.org/2000/10/swap/math#>. @prefix : <http://example.org/ns#>. :Collection :parts (:part1 :part2 :part3). { ?subject :parts ?parts. ?parts rdf:first ?part. ?parts rdf:rest ?rest. ?rest math:memberCount ?count. } => { ?part :order ?count . ?x :parts ?rest . }. giving $ cwm /tmp/count.n3 --think --data #Processed by Id # using base file:///tmp/count.n3 @prefix : <http://example.org/ns#> . :Collection :parts ( :part1 :part2 :part3 ) . :part1 :order 2 . :part2 :order 1 . :part3 :order 0 . Jos -- https://josd.github.io On Fri, Jul 22, 2022 at 8:54 PM William Van Woensel < william.vanwoensel@gmail.com> wrote: > 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 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#>. > > { > ?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 19:09:46 UTC