How about multi-field slots?
Group A {
Group B;
Group C;
Node A;
Node B;
}
To establish the above Group with can i pattern match on
If (slot-group (schema GroupA) (values B C))
(slot-node (schema GroupA) (values A B))
=>
do something.
How does the inheritence level work for a recursive object? Can you give an
example?
Thanks
Satish.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 27, 2001 8:23 AM
To: Satish boggavarapu
Cc: '[EMAIL PROTECTED]'; '[EMAIL PROTECTED]'
Subject: Re: JESS: Representing a recursive attribute as a slot.
The structure of a pattern has to be fixed when a rule is compiled for
pattern-matching to work. The rule compiler translates slot names into
absolute numeric offsets within a Fact; dynamic slot lookup by name is
-not- done at runtime. This question is usually asked in the form
"I've got a hashtable of named values, and I want to pattern-match on
the contents. How do I do that?" The answer is that sorry, you can't.
Given that, Jess does offer a single-inheritance model for
deftemplates, and if you canorganize your structures into a Java-like
inheritance tree, then you can write rules which operate on the
various levels of that tree. Furthermore, you can use the
(fact-slot-value) function to extract additional slot values of
polymorephic types in a (test) CE, although this wno't be nearly so
efficient as matching named slots.
I think Satish boggavarapu wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
>
> Consider the following scenario.
>
> class Group {
> Node node;
> Group group;
> }
>
> An instance of group can have only nodes, only groups, or a combination of
> groups and nodes.
>
> GroupA {
> GroupB;
> GroupC;
> }
>
> GroupB {
> NodeA;
> NodeB;
> GroupD;
> }
>
> GroupC {
> NodeC;
> }
>
> GroupD {
> NodeD;
> NodeE;
> }
>
>
> In the above situation how do i define a deftemplate suitable for those
> slots (not for class). I need a deftemplate like (slotname (schema ?obj)
> (value ?val)). I am trying to make the group follow a composite design
> pattern. Is there a good way to do this? Once i assert the components of
the
> group, to pattern match do i have to fist establish the sub groups to
> establish the group like
>
> If (NodeD & NodeE) => GroupD;
> If (NodeC) => GroupC;
> If (GroupD & NodeA & NodeB) => GroupB;
> If (GroupB & GroupC) => GroupA
>
> Is this the way i achieve this?
>
> Thanks in advance.
> Satish.
>
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 23, 2001 8:39 PM
> To: Satish boggavarapu
> Cc: '[EMAIL PROTECTED]'
> Subject: Re: JESS: Representing a recursive attribute as a slot.
>
>
> I'm not sure what you're asking here. You're certainly free to define
> a deftemplate and use one of the slots to store references to other
> Fact objects, as been discussed many times recently on this list --
> i.e.,
>
> (defrule example-1
> ?x <- (some-fact)
> =>
> (assert (some-fact (link ?x))))
>
> (defrule example-2
> (some-fact (link ?y))
> =>
> (printout t (fact-slot-value ?y link) crlf))
>
> (defrule example-3
> ?z <- (some-fact)
> ?q <- (some-fact (link ?z))
> =>
> (printout t ?q " is linked to " ?z crlf))
>
>
> I think Satish boggavarapu wrote:
> [Charset iso-8859-1 unsupported, filtering to ASCII...]
> >
> > Hi,
> >
> > If i have an object which has itself as an attribute, how do i represent
> > that attribute as (slotname (schema ?obj) (value ?val)).
> >
> > class Group {
> > Node node;
> > Group group;
> > }
> >
> > Thanks in advance.
> > Satish
> >
> >
> > ---------------------------------------------------------------------
> > 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]
> > ---------------------------------------------------------------------
> >
>
>
>
> ---------------------------------------------------------
> Ernest Friedman-Hill
> Distributed Systems Research Phone: (925) 294-2154
> Sandia National Labs FAX: (925) 294-2234
> Org. 8920, MS 9012 [EMAIL PROTECTED]
> PO Box 969 http://herzberg.ca.sandia.gov
> Livermore, CA 94550
>
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9012 [EMAIL PROTECTED]
PO Box 969 http://herzberg.ca.sandia.gov
Livermore, CA 94550
---------------------------------------------------------------------
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]
---------------------------------------------------------------------
---------------------------------------------------------------------
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]
---------------------------------------------------------------------