question about list utilities



Thanks to Barton, Stavros, and Milan for the comments and suggestions.

I'll change the code a bit, run some tests, and send an updated
version.

An apology,  comment, and two questions:

1. The apologf;
     The code I posted consisted of a bunch of fragments
    from several other *.mac files which I am using.  I put them all
    together, removed various parts, and posted the
    'dist_utilities.mac' file.  When I tested this file, I thought I
    had all necessary included utilities.  But, e.g., the 'inprod'
    routine is in the built-in package 'eigen'
       I load this package in my startup file, so it got automatically
    loaded for the file 'dist_utilities.mac'  I'll try to be more
    careful in the future.
   The routine List_Max_3 was a testing routine used in the creation
    of List_Max_2, etc.  It should not even have been in the file.

2. The comment:

   The 'pmin_dist(p,list)'  routine gives the minimal distance from the
    point p to the various points in the list 'list' along with the
   index of a point in the list 'list' where the minimum is actually
   achieved.

    The routine 'pmin_line(p,list) ' constructs the line seqment
    joining p to the output of 'pmin_list(p,list).

    The pmax_dist, pmax_line routines are similar.

3. The questions:
     a. How do I save and reload compiled functions.


        For instance, I can do

        compile(List_Min_2);

        But, I want to save and reload the compiled thing and not
        simply
        do this every time I want to use it.

        Is this done using the 'compile_file' routine? Or is there
        another
        one?  An example would be appreciated.

     b. In trying to set up, e.g., a  'Max' function for a list, one
     can do it as

          for li in list do
             z: max(z,li)
             return(z)

        or one can do

           sort(list),
           return(last(list))

        In the second case, one is doing a sort which requires more
        operations.

         After compiling, should it make much difference, say on lists
        of length <= 50000  ?


TIA,
  -sen



  ---------------------------------------------------------------------------
  | Sheldon E. Newhouse            |    e-mail: sen1 at math.msu.edu           |
  | Mathematics Department         |       				   |
  | Michigan State University      | telephone: 517-355-9684                |
  | E. Lansing, MI 48824-1027 USA  |       FAX: 517-432-1562                |
  ---------------------------------------------------------------------------

On Thu, 12 Apr 2007, Milan Lukic wrote:

> Hi Sheldon,
>
> This seems to work fine - I had to suply a definition for inprod,
> though. There are a few things I don't understand. I am not sure that
> there is any advantage in defining Max and Min, over already existing
> max, min functions in Maxima. Also, I don't see any advantage in
> defining List_Max (or List_Min), over doing something like
> apply(max,[1,2,3]). I failed to see difference between List_Min_2 and
> List_Min_3. Finally, I don't think I understand the output of
> pmax_line and pmin_line. Is it a list of min/max distances from 500
> line segments joining ??
>
> Thanks,
> Milan
>