On Mon, Mar 15, 2010 at 3:08 PM, Topi Rinkinen <maxima at topisoft.fi> wrote:
> ? ? ? ?f(t):=[1,2,3,4,5,6,7,8,9][floor(t)+1];
> ? ? ? ?plot2d([f(x)], [x,1,5], [y,0,9],[nticks,200]);
>
> gives:
>
> ? ? ? ?Subscript must be an integer:floor(x)+1#0: f(t=x) -- an error.
The subscript of a literal list must be a literal integer.
That's not consistent with Maxima's generally relaxed
attitude toward partial evaluation, so from my point of
view it's a bug. But for the moment let's try to think of
a work-around.
How about this:
L : [1, 2, 3, 4, 5, 6, 7, 8, 9];
f(t) := 'L[floor(t) + 1];
plot2d ([f(x)], [x, 1, 5], [y, 0, 9], [nticks, 200]);
The single quote ' applied to L[whatever] postpones the
evaluation of the subscripted expression. (Actually 'L[whatever]
is a so-called noun expression, meaning that it is not evaluated
even when whatever is a literal integer ... I won't go into nouns
and verbs right now.)
> * My maxima version is "Maxima 5.13.0".
My advice is to get a more recent version; that was several
releases ago and there have been many bug fixes and other
changes.
best
Robert Dodier