- From: Dan Connolly <connolly@w3.org>
- Date: Sun, 11 Nov 2001 08:36:48 -0600
- To: "Sean B. Palmer" <sean@mysterylights.com>
- CC: Tim Berners-Lee <timbl@w3.org>, www-archive+n3bugs@w3.org
"Sean B. Palmer" wrote:
>
> Hi,
>
> There's something that I've been wanting to do in N3 rules fules for
> some time now, but didn't raise the issue. Basically, I want to be
> able to do a forEach loop on members of a DAML list, such that I can
> say:-
>
> this log:forAll :x , :y .
> { :x daml:oneOf :y } log:implies [ :forEach :z; :in :y; :do { :z a
> :x } ] .
> :ClubMember daml:oneOf (:John :Mary :Fred) .
>
> and come up with:-
>
> :John a :ClubMember .
> :Mary a :ClubMember .
> :Fred a :ClubMember .
>
> Is there a way to do this already,
yes; this is a basic list-processing task; you might
take a look at some lisp/prolog books to get a feel for it.
Iterate over the members of the list recursively:
this log:forAll :l, :ll, :C, :x.
{ :C daml:oneOf :l } log:implies { :l :listMembers :C }.
{ :l :listMembers :C; ont:first :x } log:implies { :x a :C }.
{ :l :listMembers :C; ont:rest :ll } log:implies { :ll :listMembers :C
}.
Beware... the list handling in cwm changed a while ago;
I'm not sure first/rest are the right properties any more.
But whatever replaced them can be exploited the same way.
[...]
> (:mail :name) a :UnambiguousPropertySet .
That's a more complex case, but not fundamentally different.
--
Dan Connolly, W3C http://www.w3.org/People/Connolly/
Received on Sunday, 11 November 2001 09:37:13 UTC