HP Forums
Free42 question - SIGN - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: Not HP Calculators (/forum-7.html)
+--- Forum: Not quite HP Calculators - but related (/forum-8.html)
+--- Thread: Free42 question - SIGN (/thread-17458.html)



Free42 question - SIGN - Werner - 09-10-2021 08:40 AM

Hello Thomas,
About the new 'list' type: what will SIGN produce?
Up until now, SIGN could be executed on ANY object in X.
Can't remember where, but I have made explicit use of that fact in the past.
It would seem logical that it performs SIGN on all its elements, so:
Will all the commands that work on matrices also work on a list (ie on all its elements)?
SIN, IP, FP, SIGN, ...

Cheers, Werner


RE: Free42 question - SIGN - Thomas Okken - 09-10-2021 11:38 AM

On the HP-41C, SIGN was used to detect strings: it returns 0 for strings (and 1 for 0, unlike SIGN in BASIC, which returns 0 for 0).
On the HP-42S, there are specific functions for detecting types: REAL?, CPX?, MAT?, and STR?... and in that spirit, I added LIST? as well.

As for making all built-in functions work on lists in an element-wise fashion... Hmm, yes, that is a possibility. I'll have to think a bit about the details. I see RPL does this, but not recursively, so you can do, say, { 2 3 } SQ, but not { 2 3 { 5 7 } } SQ.


RE: Free42 question - SIGN - Werner - 09-10-2021 12:20 PM

Not all functions work on a matrix (well you know, of course), eg
5 x
works, but
5 MOD
does not, for some reason..
Werner


RE: Free42 question - SIGN - John Keith - 09-10-2021 06:20 PM

(09-10-2021 11:38 AM)Thomas Okken Wrote:  As for making all built-in functions work on lists in an element-wise fashion... Hmm, yes, that is a possibility. I'll have to think a bit about the details. I see RPL does this, but not recursively, so you can do, say, { 2 3 } SQ, but not { 2 3 { 5 7 } } SQ.

I believe that NewRPL functions are recursively listable however.