I'm a newbie to Lisp and CLIPS.
I just wondered how can I make a deftemplate-s slot to contain an
instance of other deftemplates? (Or how can I do the same with
defclasses?)
I tried to use
(type OBJECT)
but it didn't work. Please show me some example code, how to do it.
On Apr 30, 4:58 am, ·······@gmail.com" <·········@gmail.com> wrote:
> I'm a newbie to Lisp and CLIPS.
CLIPS as in mistyped CLISP, or expert system CLIPS ?
On May 1, 1:52 am, Vagif Verdi <···········@gmail.com> wrote:
> On Apr 30, 4:58 am, ·······@gmail.com" <·········@gmail.com> wrote:
>
> > I'm a newbie to Lisp and CLIPS.
>
> CLIPS as in mistyped CLISP, or expert system CLIPS ?
I meant the expert system.
·······@gmail.com" <·········@gmail.com> writes:
> I'm a newbie to Lisp and CLIPS.
> I just wondered how can I make a deftemplate-s slot to contain an
> instance of other deftemplates? (Or how can I do the same with
> defclasses?)
> I tried to use
>
> (type OBJECT)
>
> but it didn't work. Please show me some example code, how to do it.
In CL, DEFCLASS defines both a class and a type of same name.
So you can write:
(defclass wheel () ((radius :type float :initarg :radius :accessor radius)))
(defclass automobil () ((wheels :type (vector wheel) :initarg :wheels :accessor wheels)))
(make-instance 'automobil :wheels (vector (make-instance 'wheel :radius 10.0)))
--
__Pascal Bourguignon__
On Apr 30, 5:33 pm, ····@informatimago.com (Pascal J. Bourguignon)
wrote:
> ·······@gmail.com" <·········@gmail.com> writes:
> > I'm a newbie to Lisp and CLIPS.
> > I just wondered how can I make a deftemplate-s slot to contain an
> > instance of other deftemplates? (Or how can I do the same with
> > defclasses?)
> > I tried to use
>
> > (type OBJECT)
>
> > but it didn't work. Please show me some example code, how to do it.
>
> In CL, DEFCLASS defines both a class and a type of same name.
>
> So you can write:
>
> (defclass wheel () ((radius :type float :initarg :radius :accessor radius)))
> (defclass automobil () ((wheels :type (vector wheel) :initarg :wheels :accessor wheels)))
>
> (make-instance 'automobil :wheels (vector (make-instance 'wheel :radius 10.0)))
>
> --
> __Pascal Bourguignon__
Thanks for the example.
By the way I didn't find "vector" in the manual (I guess its a one
dimensional array, but I'd like to look up the usage syntax) , which
dialect are you using? I'm using the one from http://clipsrules.sourceforge.net/
·······@gmail.com" <·········@gmail.com> writes:
> On Apr 30, 5:33 pm, ····@informatimago.com (Pascal J. Bourguignon)
> wrote, in Common Lisp:
>> (defclass wheel () ((radius :type float :initarg :radius :accessor radius)))
>> (defclass automobil () ((wheels :type (vector wheel) :initarg :wheels :accessor wheels)))
>> (make-instance 'automobil :wheels (vector (make-instance 'wheel :radius 10.0)))
>
> Thanks for the example.
> By the way I didn't find "vector" in the manual (I guess its a one
> dimensional array, but I'd like to look up the usage syntax) , which
> dialect are you using? I'm using the one from http://clipsrules.sourceforge.net/
It's a Common Lisp type.
http://www.lispworks.com/documentation/HyperSpec/Body/a_vector.htm
http://www.lispworks.com/documentation/HyperSpec/Front/
I notice that COOL defclass has not exactly the same syntax as CLOS defclass.
(COOL = CLIPS Object Oriented Language
CLOS = Common Lisp Object System)
I fail to find much about arrays either in clipsrules.sourceforge.net
documentation, so I guess you'd have to write something like:
;; clips code follow, not common lisp:
;; See http://clipsrules.sourceforge.net/documentation/v630/bpg.htm
(defclass wheel
(slot radius (default 0.5))) ; meters
(defclass automobil
(is-a vehicule)
(multi-slot wheels (default (make-instance of wheel)
(make-instance of wheel)
(make-instance of wheel)
(make-instance of wheel))
(access read-write)))
--
__Pascal Bourguignon__
On May 5, 10:07 am, ····@informatimago.com (Pascal J. Bourguignon)
wrote:
> ·······@gmail.com" <·········@gmail.com> writes:
> > On Apr 30, 5:33 pm, ····@informatimago.com (Pascal J. Bourguignon)
> > wrote, in Common Lisp:
> >> (defclass wheel () ((radius :type float :initarg :radius :accessor radius)))
> >> (defclass automobil () ((wheels :type (vector wheel) :initarg :wheels :accessor wheels)))
> >> (make-instance 'automobil :wheels (vector (make-instance 'wheel :radius 10.0)))
>
> > Thanks for the example.
> > By the way I didn't find "vector" in the manual (I guess its a one
> > dimensional array, but I'd like to look up the usage syntax) , which
> > dialect are you using? I'm using the one fromhttp://clipsrules.sourceforge.net/
>
> It's a Common Lisp type.http://www.lispworks.com/documentation/HyperSpec/Body/a_vector.htm
>
> http://www.lispworks.com/documentation/HyperSpec/Front/
>
> I notice that COOL defclass has not exactly the same syntax as CLOS defclass.
> (COOL = CLIPS Object Oriented Language
> CLOS = Common Lisp Object System)
>
> I fail to find much about arrays either in clipsrules.sourceforge.net
> documentation, so I guess you'd have to write something like:
>
> ;; clips code follow, not common lisp:
> ;; Seehttp://clipsrules.sourceforge.net/documentation/v630/bpg.htm
>
> (defclass wheel
> (slot radius (default 0.5))) ; meters
>
> (defclass automobil
> (is-a vehicule)
> (multi-slot wheels (default (make-instance of wheel)
> (make-instance of wheel)
> (make-instance of wheel)
> (make-instance of wheel))
> (access read-write)))
>
> --
> __Pascal Bourguignon__
Thank you.