- From: tim duval <tim.duval11@gmail.com>
- Date: Fri, 22 Jul 2022 15:17:28 -0400
- To: Jos De Roo <josderoo@gmail.com>
- Cc: William Van Woensel <william.vanwoensel@gmail.com>, Patrick Hochstenbach <Patrick.Hochstenbach@ugent.be>, "public-n3-dev@w3.org" <public-n3-dev@w3.org>
- Message-ID: <CAA8RyBghBn9oAvUVJzmhCMM_mNsXcjFsCjE21AF8e9cK4+oE+g@mail.gmail.com>
[image: garthwaynes-praising.gif] On Fri, Jul 22, 2022 at 3:10 PM Jos De Roo <josderoo@gmail.com> wrote: > 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 >> >> >>
Attachments
- image/gif attachment: garthwaynes-praising.gif
Received on Friday, 22 July 2022 19:17:53 UTC