CW%APG.PH.UCL.AC.UK@pucc.PRINCETON.EDU (04/04/91)
Hi,
I don't think I was very lucid yesterday and so here are some
concise explanations of the routines at #371Dh and #3685h.
i) Given an n-dimensional array of any type in level one of
the stack and a system binary in level 2 of the stack thus-
1: <Nh>
2: Array of whatever
Then #371Dh SYSEVAL will extract the N'th object of the
array. (arrays are stored linearly as one object after another
and N represents the position in that line). For one dimensional
arrays this number is simply the position in the array eg
Array of whatever = [ 11 22 ]
then N=1 produces 11
N=2 produces 22
N=3 produces garbage!
(I've just noticed I got the array levels wrong in my stack
diagram, BEWARE) (I can't go back and edit it now)
For two dimensional array you just need to ignore the extra []'s
Array of whatever = [ [ 11 22 ]
[ 33 44 ] ]
N=1 produces 11
N=2 produces 22
N=3 produces 33
N=4 produces 44
You see its quit logical Captain!
ii) The routine at #3685h actually calculates N for you
given the position of the element of the array you
want to look at.
Given a list of ndims integers on level 2 of the stack
( sorry I meant system binaries ), where ndims is the
number of dimensions of the array, and the array of
any sort on level on the stack, thus-
2: { <N1h> <N2h> ... <Nndimsh> }
1: Array of any sort
then #3685h SYSEVAL will tell you the position of the
element at (N1,N2,...,Nndims) along the line as it were
Example:
with array of any type = [[ 1 2 3 ]
[ 4 5 6 ]]
{ <1h> <3h> } produces <3h>
{ <2h> <2h> } produces <5h>
and so on.....
The shorts produced by this routine can then be used
by the routine at #371Dh to extract the number at that
position.
NOTES: Both routines leave the answer in level 2 of the stack
and an External on level 1. The External is a True or False
depending on whether the routine was successful or not. If the
routine was unsuccessful then there is no answer on level 2
Most of the time all you have to do is DROP the external.
The beauty of these routines is that they work on any
arrays of any type of any dimension.
Conrad