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
---------------------------------------------------------------------
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]
---------------------------------------------------------------------