Accessing data in linked array on HP-50g
|
06-27-2021, 05:19 PM
(This post was last modified: 01-03-2022 10:30 PM by Giuseppe Donnini.)
Post: #5
|
|||
|
|||
RE: Accessing data in linked array on HP-50g
[ WARNING: The following information relates to the HP-48; it may also apply to the HP-50G, but no warranty is given. ]
Here are a few things you should keep in mind:
The following program, which I tentatively call LA\->, takes a linked array as argument and returns its elements in row order to the stack, followed by a list specifying its dimensions. Non-existent elements are represented by the special placeholder NOVAL. For this reason, the program will not run on an HP-48S/SX. ******************************************************************************* * LA\-> G/G+/GX only ******************************************************************************* * ABSTRACT : Dissects a linked array by returning its elements in row order, * followed by a list of its dimensions. * * STACK : ( lnkarry --> el1...eln { %dim1...%dimx } ) * * * Non-existent elements are represented by xNOVAL. * * * The dimension(s) are always returned in a list, even when the * initial argument is a vector, that is, a one-dimensional linked * array. ******************************************************************************* ASSEMBLE * Binary transfer header. NIBASC /HPHP48-K/ * Unsupported, but stable entry points: =lnkarry EQU #1CCD8 =ARRYLP_DO EQU #37BCB * Rompointer entry points: =~xNOVAL EQU #05B0AB RPL EXTERNAL xNOVAL :: CK1NoBlame ( *Require 1 argument without recording the command* ) CK&DISPATCH1 ( *Dispatch table including second, tag-stripping, pass* ) lnkarry ( *Require linked array, or tagged linked array* ) :: ( lnkarry --> ) ARRYLP_DO (DO) ( *Take apart linked array* ) INDEX@ OVER ( el1...eli-1 lnkarry #i lnkarry ) GETATELN ( el1...eli-1 lnkarry <eli TRUE>|<FALSE> ) ?SKIP ( *If element does not exist,... ) xNOVAL ( ...return xNOVAL instead* ) SWAP ( el1...eli-1 eli lnkarry ) LOOP ( el1...eln lnkarry ) DIMLIMITS ( el1...eln { #dim1...#dimx } ) INNERCOMP ( *Convert bints to reals within dimension list* ) NULL{} SWAP ZERO_DO (DO) SWAP UNCOERCE >HCOMP LOOP ( --> el1...eln { %dim1...%dimx } ) ; ; N.B. The second loop could be optimized by return stack manipulations, but since the chances of encountering a zillionth-dimensional array are reasonably low, I opted for the most legible form. A compiled version of the program, called LAto, is attached to the posting, together with three already compiled linked arrays for testing purposes:
|
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Accessing data in linked array on HP-50g - cahlucas - 06-25-2021, 05:03 PM
RE: Accessing data in linked array on HP-50g - Giuseppe Donnini - 06-26-2021, 01:53 AM
RE: Accessing data in linked array on HP-50g - cahlucas - 06-26-2021, 05:36 PM
RE: Accessing data in linked array on HP-50g - DavidM - 06-26-2021, 02:45 PM
RE: Accessing data in linked array on HP-50g - Giuseppe Donnini - 06-27-2021 05:19 PM
RE: Accessing data in linked array on HP-50g - cahlucas - 06-27-2021, 07:15 PM
RE: Accessing data in linked array on HP-50g - Giuseppe Donnini - 06-27-2021, 09:43 PM
RE: Accessing data in linked array on HP-50g - DavidM - 07-19-2021, 12:44 AM
|
User(s) browsing this thread: 2 Guest(s)