Maple zeroth entry of list or some other data structure?

99 Views Asked by At

Is it possible to change the structure of a list such that the $1$st element becomes the $0$th? That is, if $x$ is a list then $x[0]$ calls the first element of $x$.

I am writing some pseudo-codes in Maple for my Numerical Analysis course, and the index differences that I constantly have to make are a huge bother. Surely there must exist a solution?

1

There are 1 best solutions below

0
On

No. But you can use an Array (and probably should, for numerical work), and set the lower and upper index bounds to your liking. For instance,

Array( 0 .. 99 )

creates an Array of 100 elements with indices from 0 to 99. Arrays are often preferred to lists in this context because lists are immutable, while Arrays can be updated without copying the entire data structure.