Re: CWM Lists Handing Problem

Sean B. Palmer wrote:
> I think I've found a problem with handling lists. I can get the last
> element of a list using list:last (whose documentation is wrong; see
> the bottom of this email for details), but I can't get the sublist
> that the last element is the rdf:first of:
>
>
>   
You need to tell cwm which of the infinite number of lists you want.
Like this:

@prefix : <http://example.org/test#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix list: <http://www.w3.org/2000/10/swap/list#> .
@prefix string: <http://www.w3.org/2000/10/swap/string#> .

{ ?LIST a :TestList; list:last ?LAST }
 => { ?LIST :last ?LAST } .

{?LIST a :TestList} => {?LIST a :SubList} .
{?LIST a :SubList; rdf:rest ?SUBLIST} => {?SUBLIST a :SubList} .

{ ?LIST a :TestList; list:last ?LAST .
  ?SUBLIST a :SubList; rdf:first ?LAST }
 => { ?LIST :lastList ?SUBLIST } .

([ :p :q ] [ :r :s ]) a :TestList .




> #ENDS
>
> Also, the documentation for the list:last builtin is wrong:
>
> last Iff the object is a list and the subject is the last thing that
> list, then this is true. The last element can be calculated as a
> function of the list.
> - http://www.w3.org/2000/10/swap/doc/CwmBuiltins
>
> It's actually the other way around; the subject is the list, and the
> object is the last thing in that list. Please fix the description!
>
> Thanks,
>
>   

I've checked in that fix.


Yosi

Received on Friday, 12 October 2007 15:24:52 UTC