From: Steph
Subject: newbie questions
Date: 
Message-ID: <5e360e0.0301090016.1ba11ce5@posting.google.com>
Hi,
I'm totally new with LISP, so I have some very basic questions.
I have a lisp program I would like to understand as a reference to
future work.

Some of it I don't understand:
I hope one can answer my question swithout investigating the whole
program and related files. If not, I can send them too...

1.(require 'data-utilities (ml-progs-file "data-utilities"))

What does it mean? What is the meaning of each argument? If one of the
arguments is a filename, where/how do I define the full path name?

2. the whole function is:

(defun cobtrain (examples &optional root-cat)
  (unless root-cat				
    (setf root-cat (make-category))
    (add-example root-cat (pop examples)))
  (dolist (example examples)
    (cobweb example root-cat))
  root-cat)

Obviously, there are many more functions, definitions,declarations
etc.

2A)what should be the type of (make-category) ? There is no such
function in the file or other declaration of it.

2B)What is the meaning of last line (ie root-cat)? this is the input
optional argument.


3. another function is:

(defun add-example (category example)
  (push example (category-instances category))
  (incf (category-num-instances category))
  (mapc #'(lambda (value-counts value domain)
	    (unless (eq value *missing-value*)     
	      (incf (nth (position value domain) value-counts)))) 
	(category-counts category) (second example) *domains*))



domains is set in a pre loaded file:
(setf *domains* 
      '((hair feathers) (fly no-fly)...

3A) What is "category-instances " in the 2nd line? Again, it does not
appear in any structure nor as a function. What is the meaning of
"category-instances category"? Is "category-instances" a property of
"category"? Is it a method of "category"? A function applied on
"category"?

3B) What is the meaning of "mapc #'(lambda..."
How would it be written in C or VB

4.I use LispWorks personal edition 4.2.0 (XANALYS product) on win2000
PC.
How do I use the debugging tools (e.g. running the program step by
step, inserting breakpoints, etc)?
Is there a better (free) product for windows2000/PC to use?

I know it is hard to explain what the code does if you don't have the
whole picture, but still, I hope some of my questions can be answered.

Many thanks in advance,

Steph.

From: Christopher C. Stacy
Subject: Re: newbie questions
Date: 
Message-ID: <uadia8xbs.fsf@dtpq.com>
Your questions cannot be answered in much detail because they are 
very specific to the program.  You need to ask someone who knows the
program, or else (or in addition) obtain the complete source code.

 Steph> 1.(require 'data-utilities (ml-progs-file "data-utilities"))

This is requiring that a module called DATA-UTILITIES be loaded
from the indicated file.  The second argument is a filename,
and it is being computed by the function ML-PROGS-FILE.
There is no telling what ML-PROGS-FILE does or how you
are to control what filename it hopefully will yield.

As a guess, probably ML-PROGS-FILE looks at some configuration 
data to figure out the appropriate directory, and then uses
"data-utilities" as the filename for the file in that directory.
But that still doesn't answer your question, and it could be
doing absolutely anything at all to compute the filename.

You can look up REQUIRE in the online documentation.

If you don't really understand about "evaluation" in Lisp, 
or didn't recognize that you are looking at two function 
calls there, then you need to learn the basics of Lisp.
For that you will need some textbooks or lessons.

 Steph> (defun cobtrain (examples &optional root-cat)
 Steph>   (unless root-cat				
 Steph>     (setf root-cat (make-category))
 Steph>     (add-example root-cat (pop examples)))
 Steph>   (dolist (example examples)
 Steph>     (cobweb example root-cat))
 Steph>   root-cat)

 Steph> 2A)what should be the type of (make-category) ? There is no such
 Steph> function in the file or other declaration of it.

 Steph> Obviously, there are many more functions, definitions,declarations

Unless one of them is MAKE-CATEGORY, you're out of luck.
Perhaps by comprehending all the other source code that you 
have been given, you can puzzle out what it must be returning.

There is no way to know from looking at this function alone,
except that the person who wrote COBTRAIN was under the impression
that the object returned from MAKE-CATEGORY would be of some type
that is suitable for ADD-EXAMPLE.   Whatever that's all about...

 Steph> 2B)What is the meaning of last line (ie root-cat)?
 Steph> this is the input optional argument.

Yes, COBTRAIN takes an argument ROOT-CAT.  
But UNLESS it was not NIL, it defaults it to whatever
MAKE-CATEGORY returns (also doing something that involves
both the ROOT-CAT and the first of the EXAMPLES).

Then the program goes through all (or the remaining) EXAMPLES, 
doing COBWEB on each one of them and on ROOT-CAT.  Finally,
the program returns the value of ROOT-CAT.   One imagines 
that ROOT-CAT was some kind of structure such as a linked
list or an array, and that it was mutated by COBWEB,
and is finally available for further processing.

 Steph> 3. another function is:

 Steph> (defun add-example (category example)
 Steph>   (push example (category-instances category))
 Steph>   (incf (category-num-instances category))
 Steph>   (mapc #'(lambda (value-counts value domain)
 Steph> 	    (unless (eq value *missing-value*)     
 Steph> 	      (incf (nth (position value domain) value-counts)))) 
 Steph> 	(category-counts category) (second example) *domains*))

 Steph> 3A) What is "category-instances " in the 2nd line? Again, it does not
 Steph> appear in any structure nor as a function. What is the meaning of
 Steph> "category-instances category"? Is "category-instances" a property of
 Steph> "category"? Is it a method of "category"? A function applied on
 Steph> "category"?

(CATEGORY-INSTANCES CATEGORY) is simply a function call.
The function CATEGORY-INSTANCES is being called, and CATEGORY
is being passed to it.   Whether "instances" refers to anything
having to do with CLOS methods and instances is unknowable from
what you have shown here.  

The word "object" is often used by Lisp programmers to mean any data,
since all data in Lisp has latent identity and type.  When someone says
"instance", on the other hand, they mean "an instance of a CLOS class"
which might have applicable methods.

But you could also write a program that finds all "instances" of
the word "instance" in this email message.   Perhaps those instances
would be represented as instances of some class, or maybe they would
be represented by entries in a bit array or a Huffman code or just
a list of strings, or any kind of suitable data structure.
For instance.

 Steph> 3B) What is the meaning of "mapc #'(lambda..."

You can look up MAPC and LAMBDA in your Lisp text book.
If you don't have one, use the "HyperSpec" online reference manual.
(The HyperSpec is not a tutorial, however.  It is based on the
ANSI spec for the language, and is available from the Help menu.)

The short answer is that LAMBDA is the name you give to anonymous
functions that really don't need their own name.  It is taking
arguments VALUE-COUNTS, VALUE, and DOMAIN, see?   

MAPC is used to map a function over a sequence of arguments.
The first argument to MAPC is that anonymous function; the
remaining arguments to MAPC are three sequences, one for
each of the arguments to the anonymous function above.

 Steph> How would it be written in C or VB

Just as some kind of procedural loop, rather than the more 
functional style that MAPC and related functions offer.
It could have been done using the more familar feeling
DOLIST function, used in COBTRAIN, but MAPC was easier
Read the documentation for MAPC to learn why.

 Steph> 4.I use LispWorks personal edition 4.2.0 (XANALYS product) on win2000 PC.
 Steph> How do I use the debugging tools (e.g. running the program step by
 Steph> step, inserting breakpoints, etc)?

Read the (online) Help that comes with the product.
TRACE and STEP are useful.

 Steph> Is there a better (free) product for windows2000/PC to use?

That's a matter of opinion.  LispWorks is one of the two most
elaborate and comprehensive Lisp environments for the PC, 
and it is quite excellent.

 Steph> I know it is hard to explain what the code does if you don't have the
 Steph> whole picture, but still, I hope some of my questions can be answered.

You're going to have to learn Lisp, and you're going to also 
have to learn this particular program you've been given.
LispWorks comes with extensive docuentation, but if you don't really
know Lisp, you will need to learn many things from a textbook.
Surely you must have some idea of what the program is intended
to do, and if you're working on it, how it is designed and what
the algorithms are?  Doesn't it have any documentation?

Good luck!


PS. 

Offhand, I would guess that what you have on your hands is a concept
formation program for the creation of hierarchical classification trees, 
based on the work of Fisher, and that if you read Reich's thesis and papers, 
you will get a lot further than asking people on a newsgroup to guess how
a complicated program works from showing them little teeny code snippets!
From: Steph
Subject: Re: newbie questions
Date: 
Message-ID: <5e360e0.0301090659.9dd1a48@posting.google.com>
Christopher,
Thank you for the time and patience...
I'm really new to Lisp, and I try to find the short way getting the
code running (I write in C/VB and look at the LISP code as a
reference.
I guess there are no shortcuts here...
You are right. I do a research on unsupervised clustering and the code
is taken from Fisher cobweb algorithm.

Do you happen to know if (and where) there is an implementation of it
written in C or C++ or VB or Fortran or Pascal ?


Again, Many thanks.

Steph.


······@dtpq.com (Christopher C. Stacy) wrote in message news:<·············@dtpq.com>...
> Your questions cannot be answered in much detail because they are 
> very specific to the program.  You need to ask someone who knows the
> program, or else (or in addition) obtain the complete source code.
> 
>  Steph> 1.(require 'data-utilities (ml-progs-file "data-utilities"))
> 
> This is requiring that a module called DATA-UTILITIES be loaded
> from the indicated file.  The second argument is a filename,
> and it is being computed by the function ML-PROGS-FILE.
> There is no telling what ML-PROGS-FILE does or how you
> are to control what filename it hopefully will yield.
> 
> As a guess, probably ML-PROGS-FILE looks at some configuration 
> data to figure out the appropriate directory, and then uses
> "data-utilities" as the filename for the file in that directory.
> But that still doesn't answer your question, and it could be
> doing absolutely anything at all to compute the filename.
> 
> You can look up REQUIRE in the online documentation.
> 
> If you don't really understand about "evaluation" in Lisp, 
> or didn't recognize that you are looking at two function 
> calls there, then you need to learn the basics of Lisp.
> For that you will need some textbooks or lessons.
> 
>  Steph> (defun cobtrain (examples &optional root-cat)
>  Steph>   (unless root-cat				
>  Steph>     (setf root-cat (make-category))
>  Steph>     (add-example root-cat (pop examples)))
>  Steph>   (dolist (example examples)
>  Steph>     (cobweb example root-cat))
>  Steph>   root-cat)
> 
>  Steph> 2A)what should be the type of (make-category) ? There is no such
>  Steph> function in the file or other declaration of it.
> 
>  Steph> Obviously, there are many more functions, definitions,declarations
> 
> Unless one of them is MAKE-CATEGORY, you're out of luck.
> Perhaps by comprehending all the other source code that you 
> have been given, you can puzzle out what it must be returning.
> 
> There is no way to know from looking at this function alone,
> except that the person who wrote COBTRAIN was under the impression
> that the object returned from MAKE-CATEGORY would be of some type
> that is suitable for ADD-EXAMPLE.   Whatever that's all about...
> 
>  Steph> 2B)What is the meaning of last line (ie root-cat)?
>  Steph> this is the input optional argument.
> 
> Yes, COBTRAIN takes an argument ROOT-CAT.  
> But UNLESS it was not NIL, it defaults it to whatever
> MAKE-CATEGORY returns (also doing something that involves
> both the ROOT-CAT and the first of the EXAMPLES).
> 
> Then the program goes through all (or the remaining) EXAMPLES, 
> doing COBWEB on each one of them and on ROOT-CAT.  Finally,
> the program returns the value of ROOT-CAT.   One imagines 
> that ROOT-CAT was some kind of structure such as a linked
> list or an array, and that it was mutated by COBWEB,
> and is finally available for further processing.
> 
>  Steph> 3. another function is:
> 
>  Steph> (defun add-example (category example)
>  Steph>   (push example (category-instances category))
>  Steph>   (incf (category-num-instances category))
>  Steph>   (mapc #'(lambda (value-counts value domain)
>  Steph> 	    (unless (eq value *missing-value*)     
>  Steph> 	      (incf (nth (position value domain) value-counts)))) 
>  Steph> 	(category-counts category) (second example) *domains*))
> 
>  Steph> 3A) What is "category-instances " in the 2nd line? Again, it does not
>  Steph> appear in any structure nor as a function. What is the meaning of
>  Steph> "category-instances category"? Is "category-instances" a property of
>  Steph> "category"? Is it a method of "category"? A function applied on
>  Steph> "category"?
> 
> (CATEGORY-INSTANCES CATEGORY) is simply a function call.
> The function CATEGORY-INSTANCES is being called, and CATEGORY
> is being passed to it.   Whether "instances" refers to anything
> having to do with CLOS methods and instances is unknowable from
> what you have shown here.  
> 
> The word "object" is often used by Lisp programmers to mean any data,
> since all data in Lisp has latent identity and type.  When someone says
> "instance", on the other hand, they mean "an instance of a CLOS class"
> which might have applicable methods.
> 
> But you could also write a program that finds all "instances" of
> the word "instance" in this email message.   Perhaps those instances
> would be represented as instances of some class, or maybe they would
> be represented by entries in a bit array or a Huffman code or just
> a list of strings, or any kind of suitable data structure.
> For instance.
> 
>  Steph> 3B) What is the meaning of "mapc #'(lambda..."
> 
> You can look up MAPC and LAMBDA in your Lisp text book.
> If you don't have one, use the "HyperSpec" online reference manual.
> (The HyperSpec is not a tutorial, however.  It is based on the
> ANSI spec for the language, and is available from the Help menu.)
> 
> The short answer is that LAMBDA is the name you give to anonymous
> functions that really don't need their own name.  It is taking
> arguments VALUE-COUNTS, VALUE, and DOMAIN, see?   
> 
> MAPC is used to map a function over a sequence of arguments.
> The first argument to MAPC is that anonymous function; the
> remaining arguments to MAPC are three sequences, one for
> each of the arguments to the anonymous function above.
> 
>  Steph> How would it be written in C or VB
> 
> Just as some kind of procedural loop, rather than the more 
> functional style that MAPC and related functions offer.
> It could have been done using the more familar feeling
> DOLIST function, used in COBTRAIN, but MAPC was easier
> Read the documentation for MAPC to learn why.
> 
>  Steph> 4.I use LispWorks personal edition 4.2.0 (XANALYS product) on win2000 PC.
>  Steph> How do I use the debugging tools (e.g. running the program step by
>  Steph> step, inserting breakpoints, etc)?
> 
> Read the (online) Help that comes with the product.
> TRACE and STEP are useful.
> 
>  Steph> Is there a better (free) product for windows2000/PC to use?
> 
> That's a matter of opinion.  LispWorks is one of the two most
> elaborate and comprehensive Lisp environments for the PC, 
> and it is quite excellent.
> 
>  Steph> I know it is hard to explain what the code does if you don't have the
>  Steph> whole picture, but still, I hope some of my questions can be answered.
> 
> You're going to have to learn Lisp, and you're going to also 
> have to learn this particular program you've been given.
> LispWorks comes with extensive docuentation, but if you don't really
> know Lisp, you will need to learn many things from a textbook.
> Surely you must have some idea of what the program is intended
> to do, and if you're working on it, how it is designed and what
> the algorithms are?  Doesn't it have any documentation?
> 
> Good luck!
> 
> 
> PS. 
> 
> Offhand, I would guess that what you have on your hands is a concept
> formation program for the creation of hierarchical classification trees, 
> based on the work of Fisher, and that if you read Reich's thesis and papers, 
> you will get a lot further than asking people on a newsgroup to guess how
> a complicated program works from showing them little teeny code snippets!
From: Christopher C. Stacy
Subject: Re: newbie questions
Date: 
Message-ID: <uadiadrss.fsf@dtpq.com>
>>>>> On 9 Jan 2003 06:59:37 -0800, Steph  ("Steph") writes:
 Steph> Do you happen to know if (and where) there is an
 Steph> implementation of it written in C or C++ or VB or Fortran or Pascal ?

Unfortnately, I do not.  Well, but maybe that's actually fortunate
for you!  Once you get the hang of it, you will find that Lisp is
a much easier programming language than those others, especially
for complex programs.  (That's why the original author used Lisp!)

 Steph> Again, Many thanks.

You're very welcome!
From: Christopher C. Stacy
Subject: Re: newbie questions
Date: 
Message-ID: <u65sy8x9h.fsf@dtpq.com>
(Okay, that was my penance for saying stupid things earlier today...)
From: Kenny Tilton
Subject: Re: newbie questions
Date: 
Message-ID: <3E1D722A.40409@nyc.rr.com>
Steph wrote:
> 2A)what should be the type of (make-category) ? There is no such
> function in the file or other declaration of it.

Taking a random example out of the blue (don't know why I chose this 
from all the code I have over here):

(defstruct cell
   waking-state
   model
   slot-spec
   value
   )

causes functions make-cell and copy-cell to be defined. Also functions 
to access the components of the cell structure: cell-waking-state, 
cell-model, cell-slot-spec, and cell-value.

So your searches of the code were stymied by this autogen behavior.

> 
> 2B)What is the meaning of last line (ie root-cat)? this is the input
> optional argument.

Lisp functions return the last form evaluated. So you do not have to 
forever be typing in "(return ...)" As for why the input argument is 
kinda tossed in outta nowhere as the return argument, it is common 
practice to return the input parameter just so another function can have 
a go at the same structure in nested code, without getting into a 
sequence of lines:

(do-something-else-with
    (do-that-with
      (do-this-with some-key-structure)))

instead of


(do-this-with some-key-structure)
(do-that-with some-key-structure)
(do-something-else-with some-key-structure)

> 
> 

> 3A) What is "category-instances " in the 2nd line? Again, it does not
> appear in any structure nor as a function.

Covered above. It suggests to me that the structure category has a 
component called instances.

  What is the meaning of
> "category-instances category"? Is "category-instances" a property of
> "category"? Is it a method of "category"? A function applied on
> "category"?

Right, the latter, a function applied to a category which returns the 
property instances. btw, the type of the category would be category, 
tested thus: (typep suspected-category 'category)

> 
> 3B) What is the meaning of "mapc #'(lambda..."
> How would it be written in C or VB

void count-values (counts *valueCounts, VALUE value, DOMAIN domain) {
      if ( !valuecmp( value, globalMissingValue) )
         ++valueCounts[ position( value, domain ) ];
}

Now write a wicked hairy function that takes four argyments, a callback 
and three lists. In there write a for statement that:

(a) intializes three variables to the first thing in each of three 
lists: catcounts, secondExample, and the global *domains*

(b) tests that it found a thing in each of the three lists

(c) continues by taking the next thing in each list

and in the body: (*callback)(thing1, thing2, thing3)


Something like that. ie, mapc calls the anonymous (lambda (a b c)....) 
on the things from three lists, one from col a, one from col b, etc 
untilt he shortest list runs out.



-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Cells let us walk, talk, think, make love and realize
  the bath water is cold." -- Lorraine Lee Cudmore
From: Steph
Subject: Re: newbie questions
Date: 
Message-ID: <5e360e0.0301092242.4dae3635@posting.google.com>
Kenny,
Thanks for the good explanations and samples.
I hope I can start writing my own program based on the reference and
your explanations (and others).

Steph.

Kenny Tilton <·······@nyc.rr.com> wrote in message news:<··············@nyc.rr.com>...
> Steph wrote:
> > 2A)what should be the type of (make-category) ? There is no such
> > function in the file or other declaration of it.
> 
> Taking a random example out of the blue (don't know why I chose this 
> from all the code I have over here):
> 
> (defstruct cell
>    waking-state
>    model
>    slot-spec
>    value
>    )
> 
> causes functions make-cell and copy-cell to be defined. Also functions 
> to access the components of the cell structure: cell-waking-state, 
> cell-model, cell-slot-spec, and cell-value.
> 
> So your searches of the code were stymied by this autogen behavior.
> 
> > 
> > 2B)What is the meaning of last line (ie root-cat)? this is the input
> > optional argument.
> 
> Lisp functions return the last form evaluated. So you do not have to 
> forever be typing in "(return ...)" As for why the input argument is 
> kinda tossed in outta nowhere as the return argument, it is common 
> practice to return the input parameter just so another function can have 
> a go at the same structure in nested code, without getting into a 
> sequence of lines:
> 
> (do-something-else-with
>     (do-that-with
>       (do-this-with some-key-structure)))
> 
> instead of
> 
> 
> (do-this-with some-key-structure)
> (do-that-with some-key-structure)
> (do-something-else-with some-key-structure)
> 
> > 
> > 
>  
> > 3A) What is "category-instances " in the 2nd line? Again, it does not
> > appear in any structure nor as a function.
> 
> Covered above. It suggests to me that the structure category has a 
> component called instances.
> 
>   What is the meaning of
> > "category-instances category"? Is "category-instances" a property of
> > "category"? Is it a method of "category"? A function applied on
> > "category"?
> 
> Right, the latter, a function applied to a category which returns the 
> property instances. btw, the type of the category would be category, 
> tested thus: (typep suspected-category 'category)
> 
> > 
> > 3B) What is the meaning of "mapc #'(lambda..."
> > How would it be written in C or VB
> 
> void count-values (counts *valueCounts, VALUE value, DOMAIN domain) {
>       if ( !valuecmp( value, globalMissingValue) )
>          ++valueCounts[ position( value, domain ) ];
> }
> 
> Now write a wicked hairy function that takes four argyments, a callback 
> and three lists. In there write a for statement that:
> 
> (a) intializes three variables to the first thing in each of three 
> lists: catcounts, secondExample, and the global *domains*
> 
> (b) tests that it found a thing in each of the three lists
> 
> (c) continues by taking the next thing in each list
> 
> and in the body: (*callback)(thing1, thing2, thing3)
> 
> 
> Something like that. ie, mapc calls the anonymous (lambda (a b c)....) 
> on the things from three lists, one from col a, one from col b, etc 
> untilt he shortest list runs out.
From: Thomas A. Russ
Subject: Re: newbie questions
Date: 
Message-ID: <ymilm1s8xao.fsf@sevak.isi.edu>
Kenny Tilton <·······@nyc.rr.com> writes:

> > 2B)What is the meaning of last line (ie root-cat)? this is the input
> > optional argument.
> 
> Lisp functions return the last form evaluated. So you do not have to 
> forever be typing in "(return ...)" As for why the input argument is 
> kinda tossed in outta nowhere as the return argument, it is common 
> practice to return the input parameter just so another function can have 
> a go at the same structure in nested code, without getting into a 
> sequence of lines:

The other reason is that in the initial function in question, that input
variable may be assigned to:

  >> (defun cobtrain (examples &optional root-cat)
  >>   (unless root-cat
  >>     (setf root-cat (make-category))
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  >>     (add-example root-cat (pop examples)))
  >>   (dolist (example examples)
  >>     (cobweb example root-cat))
  >>   root-cat)

If that assignment is executed, the only way to get the value back out
of the function is to return it, since variable bindings can't be
changed (in Lisp) by a called function.  The variable value can be
mutated, but that is not the same thing.


-- 
Thomas A. Russ,  USC/Information Sciences Institute          ···@isi.edu    
From: Coby Beck
Subject: Re: newbie questions
Date: 
Message-ID: <avjq2d$4ur$1@otis.netspace.net.au>
"Steph" <···········@hotmail.com> wrote in message
································@posting.google.com...
> (defun cobtrain (examples &optional root-cat)
>   (unless root-cat
>     (setf root-cat (make-category))
>     (add-example root-cat (pop examples)))
>   (dolist (example examples)
>     (cobweb example root-cat))
>   root-cat)
>
> Obviously, there are many more functions, definitions,declarations
> etc.
>
> 2A)what should be the type of (make-category) ? There is no such
> function in the file or other declaration of it.

Probably you have somewhere in your code
(defstruct category .... )
with at least the slots instances, counts and num-instances.  When you use
defstruct it creates a lot of functions as a side effect.  In this presumed
case you get make-category, category-instances, category-num-instances,
category-counts and category-<whatever> for whatever other slots there are.
These are default names and can be overridden in your defstruct form.


> 2B)What is the meaning of last line (ie root-cat)? this is the input
> optional argument.

putting root-cat as the last form in the function means that is the returned
value.

> 3. another function is:
>
> (defun add-example (category example)
>   (push example (category-instances category))
>   (incf (category-num-instances category))
>   (mapc #'(lambda (value-counts value domain)
>     (unless (eq value *missing-value*)
>       (incf (nth (position value domain) value-counts))))
> (category-counts category) (second example) *domains*))
>
>
>
> domains is set in a pre loaded file:
> (setf *domains*
>       '((hair feathers) (fly no-fly)...
>
> 3A) What is "category-instances " in the 2nd line? Again, it does not
> appear in any structure nor as a function. What is the meaning of
> "category-instances category"? Is "category-instances" a property of
> "category"? Is it a method of "category"? A function applied on
> "category"?

Should be accessors of a category structure.

> Many thanks in advance,

HTH

--
Coby Beck
(remove #\Space "coby 101 @ bigpond . com")
From: Steph
Subject: Re: newbie questions
Date: 
Message-ID: <5e360e0.0301092243.617068da@posting.google.com>
Thanks Coby. Good explanations!

"Coby Beck" <·····@mercury.bc.ca> wrote in message news:<············@otis.netspace.net.au>...
> "Steph" <···········@hotmail.com> wrote in message
> ································@posting.google.com...
> > (defun cobtrain (examples &optional root-cat)
> >   (unless root-cat
> >     (setf root-cat (make-category))
> >     (add-example root-cat (pop examples)))
> >   (dolist (example examples)
> >     (cobweb example root-cat))
> >   root-cat)
> >
> > Obviously, there are many more functions, definitions,declarations
> > etc.
> >
> > 2A)what should be the type of (make-category) ? There is no such
> > function in the file or other declaration of it.
> 
> Probably you have somewhere in your code
> (defstruct category .... )
> with at least the slots instances, counts and num-instances.  When you use
> defstruct it creates a lot of functions as a side effect.  In this presumed
> case you get make-category, category-instances, category-num-instances,
> category-counts and category-<whatever> for whatever other slots there are.
> These are default names and can be overridden in your defstruct form.
> 
> 
> > 2B)What is the meaning of last line (ie root-cat)? this is the input
> > optional argument.
> 
> putting root-cat as the last form in the function means that is the returned
> value.
> 
> > 3. another function is:
> >
> > (defun add-example (category example)
> >   (push example (category-instances category))
> >   (incf (category-num-instances category))
> >   (mapc #'(lambda (value-counts value domain)
> >     (unless (eq value *missing-value*)
> >       (incf (nth (position value domain) value-counts))))
> > (category-counts category) (second example) *domains*))
> >
> >
> >
> > domains is set in a pre loaded file:
> > (setf *domains*
> >       '((hair feathers) (fly no-fly)...
> >
> > 3A) What is "category-instances " in the 2nd line? Again, it does not
> > appear in any structure nor as a function. What is the meaning of
> > "category-instances category"? Is "category-instances" a property of
> > "category"? Is it a method of "category"? A function applied on
> > "category"?
> 
> Should be accessors of a category structure.
> 
> > Many thanks in advance,
> 
> HTH