Post Reply 
Accessing data in linked array on HP-50g
06-26-2021, 01:53 AM (This post was last modified: 06-26-2021 12:02 PM by Giuseppe Donnini.)
Post: #2
RE: Accessing data in linked array on HP-50g
(06-25-2021 05:03 PM)cahlucas Wrote:  What is the best way to access data in a linked array?

At least on the HP-48GX, the following System RPL words work interchangeably with ordinary arrays and linked arrays.

GETATELN ( #0371Dh )

# arry --> ob TRUE

# lnkarry --> ob TRUE
# lnkarry --> FALSE

where # specifies a lexicographic element number for arry or a lexicographic pointer table entry number for lnkarry. For lnkarry, GETATELN returns FALSE if the specified element does not exist. Otherwise, it returns the specified element of arry or lnkarry and TRUE.

Note that FALSE is only returned for a null pointer within the limits of a linked array, so you have to make sure that # is within the range of arry or lnkarry. This can be checked with the following words:


DIMLIMITS ( #035A9h )

arry --> {}
lnkarry --> {}

Returns a list of binary integer objects representing the dimensionality of arry or lnkarry. The length of the list represents the dimension count and the internals are the dimension limits.


ARSIZE ( #03562h )

arry --> #
lnkarry --> #

For arry, ARSIZE returns the number of elements of the array in #. For lnkarry, it returns the number of pointer table entries of the linked array in #.


(06-25-2021 05:03 PM)cahlucas Wrote:  a linked array consists of pointers pointing to the actual objects in RAM (or ROM).

No, the pointers do not point to objects, but to object bodies. Moreover, the referenced object bodies are not at liberty to live just anywhere in RAM or ROM, but must live inside the body of the containing linked array object itself, because linked arrays, like ordinary arrays, are atomic, not composite.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Accessing data in linked array on HP-50g - Giuseppe Donnini - 06-26-2021 01:53 AM



User(s) browsing this thread: 1 Guest(s)