Lisp HUG Maillist Archive

RE: Multiple clauses in KW:FINDALL

Sigh. I found the trouble. It seems I must package-qualify the TEST
operator, like this:

(kw:findall '?x '(and (hobbit ?x age ?a) (kw:test (< ?a 50))))

The only reason I stumbled upon this solution is because I happened to run a
test within the KW-USER package and it worked.

Ah well...

dey

-----Original Message-----
From: Jason Trenouth [mailto:jason.trenouth@globalgraphics.com]
Sent: Wednesday, September 29, 2004 5:13 AM
To: Young, David
Cc: 'lisp-hug@xanalys.com'
Subject: Re: Multiple clauses in KW:FINDALL


Young, David wrote:

>Hi. I would like to query our kb using something similar to the following.
>Assume I have to kw instances of class FRODO, one with age = 30, the other
>with age = 60. I then evaluate:
>
>(kw:findall '?x '(and (frodo ?x age ?age) ((< ?age 50))))
>
>However, I clearly don't understand somthing about FINDALL, as the above
>query returns *both* instances rather than just one. What am I doing wrong?
>
>  
>
I think the (( ... )) syntax just means: run the Lisp code. The result 
is not used to control the Prolog backtracking. If you want the result 
to control the backtracking then I think you have to use (test ( ... )). ie
 

	(kw:findall '?x '(and (frodo ?x age ?age) (test (< ?age 50))))

__Jason


This email message is for the sole use of the intended recipients(s) and may contain confidential and privileged information of Bloodhound Software, Inc.. Any unauthorized review, use, disclosure is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.


Re: Multiple clauses in KW:FINDALL

Young, David wrote:

>Sigh. I found the trouble. It seems I must package-qualify the TEST
>operator, like this:
>
>(kw:findall '?x '(and (hobbit ?x age ?a) (kw:test (< ?a 50))))
>
>The only reason I stumbled upon this solution is because I happened to run a
>test within the KW-USER package and it worked.
>
>Ah well...
>
>  
>
I recommend that application packages use kw.

BTW for completeness the ((...)) syntax can probably also be made to 
work if you bind to something:

(kw:findall '?x '(and (hobbit ?x age ?a) ((< ?a 50) t)))

Assuming < returns t. 

You might also find there is a Prolog predicate version:

(kw:findall '?x '(and (hobbit ?x age ?a) (< ?a 50)))

Although you may have to watch your packages again.

__Jason


Updated at: 2020-12-10 08:55 UTC