HP Forums
size(list) Results - 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: size(list) Results (/thread-21348.html)



size(list) Results - matalog - 02-23-2024 04:47 PM

I seem to run into a problem every time I try to use lists and size, as they can unexpectedly turn into a list of lists instead, and I do not naturally get the way to work with them.

Lets say I have

LOCAL DI:=idivis(711000000);
PRINT (DI);

that prints "[1,2,3,4,5,6,8.........]" Those square brackets mean it is a matrix or vector, don't they?
In the manual idivis() says it returns a list.

So, If I then:

Print size(DI);

It returns {294}. - which means that idivis is returning a list of one containing a matrix/vector of length 294? Is there not a way to have it only return a list of 294?

It is quite confusing.

How can I then access the size of DI as a number - how do I get the result of size(DI) as a number, not a list/vector/matrix.


RE: size(list) Results - Tyann - 02-23-2024 05:11 PM

Bonjour matalog
SIZE() renvoie une liste pour la dimension des matrices {lignes,colonnes}.
Pour un vecteur SIZE() considère qu'il s'agit d'une matrice à 1 seule ligne et renvoie {colonnes}.
Pour obtenir la taille sous forme de nombre vous pouvez faire GET(SIZE([vecteur]),1).
Espérant vous avoir aider.

Hello matalog
SIZE() returns a list of matrix dimensions {rows,columns}.
For a vector, SIZE() assumes it is a 1-line matrix and returns {columns}.
To obtain the size as a number, you can do GET(SIZE([vector]),1).
Hope to have helped you.


RE: size(list) Results - Didier Lachieze - 02-23-2024 05:36 PM

You can also set DI to a list with :

LOCAL DI:=mat2list(idivis(711000000));

then size(DI) will return 294.


RE: size(list) Results - Albert Chan - 02-23-2024 06:06 PM

(02-23-2024 04:47 PM)matalog Wrote:  In the manual idivis() says it returns a list.

From HP Prime help screen, Yes
From pdf "Symbolic computation and Mathematics with the calculator HP Prime", No
Quote:idivis returns the vector whose components are the divisors of an integer.

Quote:It is quite confusing.

Instead of size/SIZE, use len/dim