Re: pl-iterator
"Magnus Malm" <[email protected]> Sun, 4 Nov 2007 20:47:18 +0100
| Newsgroups | gmane.comp.ai.powerloom |
|---|---|
| Message-ID | <[email protected]> |
Hello
I get an error while using next? and %%value on pl-iterators. I have the
following in my kb:
(defconcept component)
(defconcept robot (?c component))
(assert (component arnie))
(assert (robot astrid))
(assert (robot emil))
*************
If I try to run a function using next? and %%value, like so:
(defun foo ()
(pli:load "/home/magnus/src/powerloom-3.2.15/kbs/peis.plm" nil)
(pli:change-module "PEIS")
(let* ((iter (pli:s-retrieve "all (component ?x)" stella::null-string
stella::null-string)))
(loop while (stella::next? iter) do
(print (stella::%%value iter)))))
************
I get the following error:
Type-error in KERNEL::OBJECT-NOT-CONS-ERROR-HANDLER:
|i|/PLI/@PL-ITERATOR is not of type CONS
[Condition of type TYPE-ERROR]
Restarts:
0: [ABORT-REQUEST] Abort handling SLIME request.
1: [ABORT] Return to Top-Level.
Backtrace:
0: (FOO)
*************
Now, If I listify the iterator, e.g.:
(defun bar ()
(pli:load "/home/magnus/src/powerloom-3.2.15/kbs/peis.plm" nil)
(pli:change-module "PEIS")
(let* ((iter (pli:s-retrieve "all (component ?x)" stella::null-string
stella::null-string)))
(pli:listify iter)))
***************
I get a correct output:
|l|(|i|ARNIE |i|EMIL |i|ASTRID)
*************
I could of course return this result as a string, massage it a bit (remove
the prefixes etc), and be happily on my way. Though I am curious about what
I do wrong in this case? Since the example-code diden't manage to loop over
the iterator, I am sure that either the example code is missing some vital
part, or that I am missing some obvious part myself.
I have tried both the current stable version of PowerLoom, as well as the
snapshot found on the website.
Kind regards,
--
Magnus Malm
_______________________________________________
powerloom-forum mailing list
[email protected]
http://mailman.isi.edu/mailman/listinfo/powerloom-forum