list sum and difference

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

list sum and difference

jos.deroo

while testing with euler I am getting that

@prefix : <http://eulersharp.sourceforge.net/2005/11swap/list#>.
((:a :b :c) (:d :e :f :g)) :sum (:a :b :c :d :e :f :g).
((:a :b :c :d :e :f :g) (:g :f :b :e)) :difference (:a :c :d).

using

{} => {(() ?L) :sum ?L}.
{(?L1 ?L2) :sum ?L} => {([rdf:first ?A; rdf:rest ?L1] ?L2) :sum [rdf:first
?A; rdf:rest ?L]}.

{} => {(() ?A) :remove ()}.
{(?L1 ?A) :remove ?L} => {([rdf:first ?A; rdf:rest ?L1] ?A) :remove ?L}.
{?A log:notEqualTo ?B. (?L1 ?A) :remove ?L} => {([rdf:first ?B; rdf:rest
?L1] ?A) :remove [rdf:first ?B; rdf:rest ?L]}.

{} => {(?L ()) :difference ?L}.
{(?L1 ?A) :remove ?R. (?R ?L2) :difference ?L} => {(?L1 [rdf:first ?A;
rdf:rest ?L2]) :difference ?L}.


but with those rules cwm seems to stay running
is it possible to run those rules in forward chaining mode? any other
rules that do the job?

a bit like the prolog notation, I'm also testing with (?A/?L) as shorthand
for [rdf:first ?A; rdf:rest ?L]
 
--
Jos De Roo, AGFA http://www.agfa.com/w3c/jdroo/