Given this deffunction:

(deffunction list2lambda ($?list)
    (return (eval (str-cat "(lambda (?arg) (return (eq (list "
                         (implode$ $?list)
                         ") ?arg)))" ))))

the run-query* call could even be written as simply as

  (run-query* q1 1 (list2lambda p q r ))

Ah, the beauty of Lisp ;-)
-W



On Mon, Nov 16, 2009 at 8:45 AM, Wolfgang Laun <wolfgang.l...@gmail.com>wrote:

> As a workaround, you can use a lambda for smuggling the list into the
> query:
>
> (bind ?eq-pqr (lambda (?arg) (return (eq (list p q r) ?arg))) )
>
> (defquery q1
>
>  (declare (variables ?pa ?lam))
>  (myfact (a ?pa) (b ?b) (c $?v &:(?lam $?v))
>  )
> )
>
> -W
>
>
> On Fri, Nov 13, 2009 at 7:04 PM, Ernest Friedman-Hill 
> <ejfr...@sandia.gov>wrote:
>
>> Hmmm. Indeed, you're right, and it's a limitation of the implementation,
>> not easily lifted. I'll add it to the issues list.
>>
>>
>>
>> On Nov 13, 2009, at 12:20 PM, Michael Welter wrote:
>>
>>  Can't a list be passed to defquery?
>>>
>>> (deftemplate myfact
>>>  (slot a)
>>>  (slot b)
>>>  (multislot c)
>>> )
>>>
>>> (deffacts f1
>>>  (myfact (a 1)(b 1)(c (create$ p q c)))
>>>  (myfact (a 1)(b 2)(c (create$ p q r)))
>>>  (myfact (a 1)(b 3)(c (create$ p q z)))
>>> )
>>>
>>> (defquery q1
>>>  (declare (variables ?pa ?pc))      ; $?pc throws an error
>>>  (myfact
>>>   (a ?pa)
>>>   (b ?b)
>>>   (c $?v&:(eq $?v $?pc))     ; won't work
>>>   ;(c $?v&:(eq (nth$ 1 $?v) ?pc))     ; works
>>>  )
>>> )
>>>
>>> (defrule r1
>>>  (initial-fact)
>>> =>
>>>  (try
>>>   (bind ?result (run-query* q1 1 (create$ p q r)))
>>>  catch
>>>   (printout t "query failed" crlf)
>>>  )
>>>  (while (?result next) do
>>>   (printout t
>>>     "b: " (?result getString b)
>>>   crlf)
>>>  )
>>> )
>>>
>>>
>>> Thanks
>>>
>>>
>>> --------------------------------------------------------------------
>>> To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
>>> in the BODY of a message to majord...@sandia.gov, NOT to the list
>>> (use your own address!) List problems? Notify
>>> owner-jess-us...@sandia.gov.
>>> --------------------------------------------------------------------
>>>
>>
>> ---------------------------------------------------------
>> Ernest Friedman-Hill
>> Informatics & Decision Sciences          Phone: (925) 294-2154
>> Sandia National Labs
>> PO Box 969, MS 9012                            ejfr...@sandia.gov
>> Livermore, CA 94550                             http://www.jessrules.com
>>
>>
>>
>>
>>
>>
>> --------------------------------------------------------------------
>> To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
>> in the BODY of a message to majord...@sandia.gov, NOT to the list
>> (use your own address!) List problems? Notify owner-jess-us...@sandia.gov
>> .
>> --------------------------------------------------------------------
>>
>>
>

Reply via email to