HP Forums

Full Version: HP-Prime/Xcas: vector/list indexing
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

I don't know if this has already been addressed here, but I just found this issue when I experimented a bit with ODEs in Xcas and the HP-Prime.

There's an inconsistency between the 'Home' and CAS mode:

in Home mode vector/list elements are counted starting with 1 (which is the usual way in math), but in CAS mode (and Xcas itself) the indices start with 0. :-(

Argh, that's really terrible and absolutely unusual (and unacceptable) in mathematics. I know that starting array indexing with 0 is usual practice in some programming languages, but NOT in math, and I can't believe that someone could come up with this idea.

In [a,b,c] there's a 1st, 2nd and 3rd element, but definitely no 'element 0'!


Edited: 27 Oct 2013, 2:56 p.m.

I agree. I can understand (but loathe) the need to start at 0 in a programming language, but I always write my code around this to make element 1, element 1. True, in math, this should be totally unacceptable.

Yes, just think of a program you wrote in CAS mode which uses vector elements, and now you call this program in Home mode - you'll get a complete nonsense.

Example: define v:=[a,b,c] in CAS mode

Now v[1] returns b in CAS mode and a in Home mode!?


Hear this HP? This HAS to be fixed. Preferably starting with ONE instead of ZERO. I can work around starting with ZERO, but it HAS to be consistent between modes on a single calculator.

Inside the CAS (and Xcas) you have two choices for array indices: start at 0 using [] delimiters or start at 1 using (). You just need to take care inside loop for () notation that f(j):=j+1 is ambiguous (function definition or assignation). In Xcas, you can use [[]] instead of ().

Thanks for that information. Making a note now..

Inside the CAS (and Xcas) you have two choices for array indices: start at 0 using [] delimiters or start at 1 using ().

Thanks for the info, I didn't know that () could be used for indexing.

I've just tried it and this also works in Prime's Home mode, i.e. with () the results for Home and CAS mode are the same.

So unless this issue with [] has been solved, it's definitely better to only use () for list or vector indices in the Prime.


Edited: 27 Oct 2013, 4:53 p.m.