I think MJ Hutchinson wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Thanks, great idea for the defglobal.
>
> When it comes to the rule name ( similar_rule ), what happens if this user
> function was called multiple times simultaneously? Couldn't there be
> problems with the rule over-writing itself?
Yes, each time this is called, the old rule will be replaced, so you
need to give it a unique name each time, too. Again, you can use
gensym.
And wouldn't there be siilar
> problems for the ?s1 variable?
>
No, that's a local variable in the function; no worries there.
> Cheers,
> Matt
>
>
>
> On 5/2/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> > You could use the "gensym" function to give you a unique symbol to use
> > for a variable name, and then use "build" to create your defglobal the
> > same way you've done here for the defrule; or use gensym to create a
> > symbol, but use it as a key to store your ArrayList with "store" and
> > "fetch".
> >
> >
> > I think Matthew Hutchinson wrote:
> > [Charset iso-8859-1 unsupported, filtering to ASCII...]
> > > Hi everyone,
> > >
> > > The following function is typical of the sort of code I'm writing in
> > Jess:
> > >
> > >
> > ----------------------------------------------------------------------------------
> > > (defglobal ?*similar_result_array* = (new ArrayList 0) )
> > > (deffunction dynamic-similar-search (?p1 ?p2 ?p3 ?p4)
> > > (bind ?s1 (str-cat "(defrule similar_rule ("?p1" ("?p2" \""?p3"\")
> > > ("?p4" ?qwerty)) => (call ?*similar_result_array* add ?qwerty) )"))
> > > (build ?s1)
> > > (return ?*similar_result_array*)
> > > )
> > >
> > ----------------------------------------------------------------------------------
> > >
> > > It basically just asserts a rule dynamically using some paraemters I
> > supply
> > > it. It also stores results in an ArrayList and then returns this object
---------------------------------------------------------
Ernest Friedman-Hill
Advanced Software Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://herzberg.ca.sandia.gov
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------