Is it possible to set zero-based indexing in maxima?



What exactly are the cases you care about?

If you use undeclared (hashed) arrays, you can index by anything you want,
and there is no concept of "origin":

      a[3] : 5$
      a["test"] : 23$
      a[x^2-1] : 1/sin(y)$
      a[-23.5] : '[negative,halfinteger]$
      a[-47/2] ; "My heart belongs to daddy"$   /* note this is distinct
from -23.5 */
      a[ sin ] : lambda([q],q^2/(1-q^2)) $

If you use declared arrays, they are 0-origin and go from 0..n  (not 0 ..
n-1):

   array(foo,3)$
   foo[-1] => error
   foo[0] => no problem
   foo[3] => no problem
   foo[4] => error

On the other hand, indexing of lists and matrices is 1-origin:

Indexing of lists?  e.g.    [a,b,c][2] => c rather than b
Indexing of matrices e.g. matrix([a,b],[c,d])[1,1] => d rather than a

Changing list and array indexing to 0-origin would surely break lots of
Maxima code.  But you can easily enough define, e.g.

      idx(l,i) := l[i-1]$
      setidx(l,i,val):= l[i-1]: val$
etc.

              -s

On Wed, Mar 23, 2011 at 13:57, Andrew A <scratchboom at gmail.com> wrote:

> Default one-based indexing is not suitable for me =(
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>