HP Forums
How to implement an array ? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: How to implement an array ? (/thread-5720.html)



How to implement an array ? - smp - 02-19-2016 09:38 PM

I apologize in advance for my newbie question.

I have in mind a project for my HP Prime which will not be too terribly difficult to do, but which will require three one-dimensional arrays. Two of the arrays will have 256 elements in a single row or column, and the third array will have 65536 elements in a single row or column. These arrays will hold integer numbers

I have, once again, been looking at the skimpy information about programming in HP PPL in the HP Prime User Guide, but I do not see anything about creating or using arrays.

Would I have to use matrices? My thinking had been for arrays because I only need storage for integers, and matrices want to hold real or complex numbers, and I didn't want to use up that much more memory when I don't need to.

Thanks very much, in advance, for any advice you may have to offer.

smp


RE: How to implement an array ? - DrD - 02-19-2016 10:13 PM

It sounds like you might like to use vectors, one dimensional matrices.
For example:

RANDMAT(M1,256,1,99);

Creates a random column vector, containing 256 elements. The elements will be between 1 and 99, and are saved in variable M1.

M1(5) will access the fifth element in the array, for example.


RE: How to implement an array ? - smp - 02-20-2016 12:15 AM

(02-19-2016 10:13 PM)DrD Wrote:  It sounds like you might like to use vectors, one dimensional matrices.

Thanks very much, DrD. That's what I thought when I asked about matrices.
Thanks for verifying this for me.

smp


RE: How to implement an array ? - Carlos295pz - 02-20-2016 05:05 AM

Some more facts about Matrices, Vectors and Lists as replacing Arrays
PPL - Additional Information PART I (Spanish)


RE: How to implement an array ? - cyrille de brébisson - 02-22-2016 05:59 AM

Hello,

Prime has build in 1d (vectors) and 2d (matrices) objects.
If you need 3D, you can either use lists, or use lists with matrices in them.

remember that you can access sub-elements of a list by doing L(a,b,c) where a is the index in the list and b/c indexes in the list sub-element.

cyrille