05-15-2022, 11:56 AM
In an older thread I stumbled upon the following program:
Compared to my original program I noticed that \<< CROSS \>> can be replaced by :: CROSS:
But then I noticed that also 2 was missing.
This surprised me since I wasn't aware that the frame index could be omitted.
It turns out that this doesn't work for :: DROP but only with operations that operate on two objects like :: + or :: ^.
Furthermore, it also works when these operations are wrapped within a code object like \<< CROSS \>>.
However, the following doesn't work:
We get:
DOSUBS Error:
Invalid User Function
But we can use:
Or then of course:
Which returns the expected result:
Please excuse my ignorance but is this behaviour described in the manuals?
At least in the HP 48G Series User's Guide I couldn't find anything.
Or is it just folklore like the null-tag trick?
Addendum:
It also works for more than two arguments as long as they are declared:
The result is:
It appears to work with DOLIST as well, which is nice.
However, while it works with \<< * \>> it doesn't work with :: *.
We get:
DOLIST Error:
Bad Argument Type
Code:
\<<
DUP HEAD +
:: CROSS DOSUBS
\GSLIST ABS 2 /
\>>
Compared to my original program I noticed that \<< CROSS \>> can be replaced by :: CROSS:
Code:
\<<
DUP HEAD +
2 \<< CROSS \>> DOSUBS
\GSLIST ABS 2 /
\>>
But then I noticed that also 2 was missing.
This surprised me since I wasn't aware that the frame index could be omitted.
It turns out that this doesn't work for :: DROP but only with operations that operate on two objects like :: + or :: ^.
Furthermore, it also works when these operations are wrapped within a code object like \<< CROSS \>>.
However, the following doesn't work:
Code:
{ 0 1 4 9 16 25 }
\<< SWAP - \>>
DOSUBS
We get:
DOSUBS Error:
Invalid User Function
But we can use:
Code:
{ 0 1 4 9 16 25 }
\<< \-> u v \<< v u - \>> \>>
DOSUBS
Or then of course:
Code:
{ 0 1 4 9 16 25 }
2
\<< SWAP - \>>
DOSUBS
Which returns the expected result:
Code:
{ 1 3 5 7 9 }
Please excuse my ignorance but is this behaviour described in the manuals?
At least in the HP 48G Series User's Guide I couldn't find anything.
Or is it just folklore like the null-tag trick?
Addendum:
It also works for more than two arguments as long as they are declared:
Code:
{ 1 2 3 4 5 }
\<< \-> u v w \<< u v + w * \>> \>>
DOSUBS
The result is:
Code:
{ 9 20 35 }
It appears to work with DOLIST as well, which is nice.
However, while it works with \<< * \>> it doesn't work with :: *.
We get:
DOLIST Error:
Bad Argument Type