Hello everyone,
I have the following problem. I want to find in my working
memory the ordered facts with the same second element and to generate a fact
that contains this element and the other elements after him.
So if I have the following facts:
(fact e1 a) (fact e1 b) (fact e1 c) (fact e1 d)
I want to obtain a fact like this (final e1 a b c d).
Because I didn’t know how to do this, I have tried to use
queries and generate a list with the following structure (e1 a b c d).
Unfortunately, after I run the code:
(deffacts factslist
(fact e1 a)
(fact e1 b)
(fact e1 c)
(fact e1 d))
(reset)
(defquery
search-by-name
(declare (variables ?e1))
(fact ?e1 ?e2))
(bind ?result (run-query*
search-by-name e1))
(while (?result next)
(bind ?list (create$ (?result getSymbol e1)(?result getSymbol e2))))
(printout t "List is " ?list crlf)
The result is (e1 d).
What should I do?
Best regards,
Ana