HP-Prime/Xcas: vector/list indexing « Next Oldest | Next Newest »

 ▼ fhub Unregistered Posts: 1,216 Threads: 75 Joined: Jun 2011 10-27-2013, 02:55 PM 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. ▼ Les Koller Unregistered Posts: 253 Threads: 20 Joined: Jun 2012 10-27-2013, 03:00 PM 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. ▼ fhub Unregistered Posts: 1,216 Threads: 75 Joined: Jun 2011 10-27-2013, 03:13 PM 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 ▼ Les Koller Unregistered Posts: 253 Threads: 20 Joined: Jun 2012 10-27-2013, 03:18 PM 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. ▼ parisse Unregistered Posts: 38 Threads: 0 Joined: Aug 2013 10-27-2013, 03:35 PM 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 (). ▼ Les Koller Unregistered Posts: 253 Threads: 20 Joined: Jun 2012 10-27-2013, 03:36 PM Thanks for that information. Making a note now.. fhub Unregistered Posts: 1,216 Threads: 75 Joined: Jun 2011 10-27-2013, 04:52 PM 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 4,049 12-02-2013, 01:18 PM Last Post: Alberto Candel Milestones:List of IEEE Milestones -> HP-35 AlbertTocarLoseggs 4 2,115 11-27-2013, 08:52 AM Last Post: Massimo Gnerucci (Italy) HP Prime - vector question bluesun08 3 1,796 11-18-2013, 07:26 PM Last Post: Han HP-Prime : Extracting elements from a list in RPN Miguel Toro 0 1,608 11-15-2013, 06:44 PM Last Post: Miguel Toro [HP-Prime] Picking elements from a List in a program Jean-Michel 3 1,997 11-15-2013, 04:16 AM Last Post: dg1969 Hp PRIME - how to send a list to the connectivity Kit giancarlo 1 1,326 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 2,037 11-08-2013, 02:07 PM Last Post: Patrice XCas / Prime "solve" question Nigel J Dowrick 4 2,022 11-08-2013, 04:01 AM Last Post: Nigel J Dowrick [HP-Prime CAS] Vector Calculus Library CompSystems 7 2,759 10-31-2013, 12:48 PM Last Post: Han Hp prime list function - indexing into a list Andy B (Australia) 3 1,954 10-07-2013, 01:41 AM Last Post: cyrille de BrĂ©bisson

Forum Jump: