On 3/31/07, Zoho Vignochi <zoho.vignochi at gmail.com> wrote:
> diagram(m) :=
> block ( [p],
> for i thru m do (
> p[i]:getpoints(i) ),
> plot2d ([discrete,p])
> ) $
>
> Just calling on p doesn't work but I can call on each p, (p[1], p[2]) in
> the plot command and it produces the expected output. I am looking for
> something like
>
> plot2d ([discrete, p[i],[i, 1, m]])
Couple of things to watch out for here. (1) I think we can do away
with the variable p in diagram. (p is a so-called undeclared array,
which doesn't act the way you expect it to, to judge by the code
you wrote; this is unfortunate.)
(2) plot2d([[discrete, foo], [discrete, bar]]) (i.e. a nested list of
[discrete, ...] lists) is the syntax to plot multiple lists all at once.
(3) I'd change the integer argument of diagram to a list.
So here's how I would work this ...
diagram (L) := block (map (getpoints, L), map (lambda ([x],
['discrete, x]), %%), plot2d (%%));
(Maxima recognizes %% as the preceding result in a block.)
The notation foo[x] is used for several kinds of objects in Maxima ---
lists, matrices, arrays (declared and undeclared), and memoizing
functions. Of all of these, I'd say lists are the least confusing.
Opinions may vary.
> or a for loop where I can pass the hold option to gnuplot.
>
> for j thru m do (
> plot2d ([discrete, p[j], [hold on]]) )
For the record, I couldn't figure out a way to get Maxima to tell
Gnuplot about the hold option. Every permutation of options
which I tried caused the second plot to clobber the first.
HTH
Robert