HP-Prime/Xcas: vector/list indexing



#2

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'!

Franz


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


#3

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.


#4

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!?

Franz


#5

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.


#6

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 ().


#7

Thanks for that information. Making a note now..

#8

Quote:
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.

Franz

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


Possibly Related Threads...
Thread Author Replies Views Last Post
  HP Prime: adding an entry to a vector Alberto Candel 12 678 12-02-2013, 01:18 PM
Last Post: Alberto Candel
  Milestones:List of IEEE Milestones -> HP-35 AlbertTocarLoseggs 4 306 11-27-2013, 08:52 AM
Last Post: Massimo Gnerucci (Italy)
  HP Prime - vector question bluesun08 3 219 11-18-2013, 07:26 PM
Last Post: Han
  HP-Prime : Extracting elements from a list in RPN Miguel Toro 0 235 11-15-2013, 06:44 PM
Last Post: Miguel Toro
  [HP-Prime] Picking elements from a List in a program Jean-Michel 3 281 11-15-2013, 04:16 AM
Last Post: dg1969
  Hp PRIME - how to send a list to the connectivity Kit giancarlo 1 219 11-10-2013, 11:50 AM
Last Post: Tim Wessman
  How do I decompose a list with the HP Prime. Hal Bitton in Boise 4 287 11-08-2013, 02:07 PM
Last Post: Patrice
  XCas / Prime "solve" question Nigel J Dowrick 4 298 11-08-2013, 04:01 AM
Last Post: Nigel J Dowrick
  [HP-Prime CAS] Vector Calculus Library CompSystems 7 491 10-31-2013, 12:48 PM
Last Post: Han
  Hp prime list function - indexing into a list Andy B (Australia) 3 254 10-07-2013, 01:41 AM
Last Post: cyrille de Brébisson

Forum Jump: