Post Reply 
New RPL: New Commands
12-28-2016, 06:06 PM (This post was last modified: 12-28-2016 08:47 PM by compsystems.)
Post: #1
New RPL: New Commands
Hello, the frequent use of commands in USER-RPL within my programs. I always needed the following cmds.

Please for USER-RPL programmers can tell me if they are important or not, if they were, they should be incorporated in NEW RPL?

Thank

1: WAIT CMD detecting [ON] KEY without exit the code
PHP Code:
    waitForKey
    «
"!NO CODE
!RPL
::
    CK0
    WaitForKey
    CodePl>%rc.p
;
64 CHR ASM 'waitForKey' STO
  » 

2: Operators point .+ .- ./ .* .^, which operate on each element of a vector or matrix, With the purpose of making operations outside the linear algebra

PHP Code:
@.+
[[ 
1 2 3 ]]
« AXL 1 « 5 ADD » DOLIST AXL » EVAL -> [[6 7 8]]

NEW-
RPL: [[ 1 2 3 ]] .+ -> [[6 7 8]]

@.-
1 2 3 ]
« AXL 1 « 5 » DOLIST AXL » EVAL  -> [---2]

NEW-
RPL: [ 1 2 3 .- -> [---2]

@.*
1 2 3 * -> [ 5 10 15 
NEW-
RPL: [[ 1 2 3 ]] .* -> [ 5 10 15 ]

[[ 
1 2 3 ]] * -> [[ 5 10 15 ]] 
NEW-
RPL:  [[ 1 2 3 ]] .* -> [[ 5 10 15 ]]

@./
1 2 3 / @ -> [ 1/5 2/5 3/]
NEW-
RPL: [[ 1 2 3 ]] ./ -> [ 1/5 2/5 3/]

@.*
[[ 
'a' 'b' ]
'c' 'd' ]]

[[ 
'a' 'b' ]
'c' 'd' ]]
« AXL SWAP AXL 2 « » DOLIST AXL » EVAL
->
[[ 
'a*a' 'b*b' ]
 [ 
'c*c' 'd*d' ]]

NEW-
RPL

[[ 
'a' 'b' ]
'c' 'd' ]]

[[ 
'a' 'b' ]
'c' 'd' ]] .*

->
[[ 
'a*a' 'b*b' ]
 [ 
'c*c' 'd*d' ]]

@.^
[[ 
'a' 'b' ]
'c' 'd' ]]
[[ 
'a' 'b' ]
'c' 'd' ]]
« AXL SWAP AXL 2 « » DOLIST AXL » EVAL

[[ 
'a^a' 'b^b' ]
 [ 
'c^c' 'd^d' ]] 
Thanks

http://www.hpcalc.org 20 years online
Visit this user's website Find all posts by this user
Quote this message in a reply
12-28-2016, 06:15 PM (This post was last modified: 12-28-2016 06:20 PM by Vtile.)
Post: #2
RE: New RPL: New Commands
What I have understood the userRPL do have a command KEY which do exactly that waits a keypress and returns even the key pressed (which can be dropped if not needed). Edit. or do you mean that the KEY (or WAIT) commands should also allow ON-key as trigger input.
Find all posts by this user
Quote this message in a reply
12-28-2016, 08:17 PM (This post was last modified: 12-28-2016 08:38 PM by compsystems.)
Post: #3
RE: New RPL: New Commands
(12-28-2016 06:15 PM)Vtile Wrote:  or do you mean that the KEY (or WAIT) commands should also allow ON-key as trigger input.
YES, KEY AND WAIT cmds detecting [ON] KEY without exit the code

KEY CMD detecting [ON] KEY
PHP Code:
« 0 0 -> key keyFlag
  « 
    IFERR
      
DO "LOOP" 1 DISP
      UNTIL KEY 
'keyFlag' STO keyFlag 1 ==
      
END
    THEN 101
    END
  »
» 

http://www.hpcalc.org 20 years online
Visit this user's website Find all posts by this user
Quote this message in a reply
12-29-2016, 03:16 AM
Post: #4
RE: New RPL: New Commands
(12-28-2016 06:06 PM)compsystems Wrote:  1: WAIT CMD detecting [ON] KEY without exit the code

The On key does not stop a running program in newRPL. I found it too easy to accidentally cancel a long running calculation. To stop a program, you have to do On-A-C then choose Exit.
Because of this, WAIT will certainly be able to detect the On key just like any other key (not yet implemented).

(12-28-2016 06:06 PM)compsystems Wrote:  2: Operators point .+ .- ./ .* .^, which operate on each element of a vector or matrix, With the purpose of making operations outside the linear algebra

If the operators are all defined element-by-element, then you are not operating on vectors or matrices, they are simply lists of numbers. In newRPL you can simply use list objects, and +, - / * ^ will work as you expect, element by element and recursively on a list of lists.
Find all posts by this user
Quote this message in a reply
01-16-2017, 12:17 AM
Post: #5
RE: New RPL: New Commands
Hello, a command that is important would convert normal algebraic expression to RPN,
This command was available in the hp48gx hidden directory TEACH


RPN->
PHP Code:
« OBJ->
  
IF OVER
  THEN 
-> n f
    « 1 n
      
FOR i
        
IF DUP TYPE 9 SAME
        THEN 
->RPN
        END n ROLLD
      NEXT
      
IF DUP TYPE 5 <>
      
THEN 1 ->LIST
      END
      
IF n 1 >
      
THEN 2 n
        START 
+
        
NEXT
      END f 
+
    
»
  
ELSE ->LIST SWAP DROP
  END
» 
Visit this user's website Find all posts by this user
Quote this message in a reply
01-16-2017, 04:24 PM (This post was last modified: 01-16-2017 04:25 PM by Claudio L..)
Post: #6
RE: New RPL: New Commands
(01-16-2017 12:17 AM)compsystems Wrote:  Hello, a command that is important would convert normal algebraic expression to RPN,
This command was available in the hp48gx hidden directory TEACH

What's the use case for this? You've asked for this command in multiple occasions, but never gave a reason why is this so important. The algebraic expression is evaluated in RPN way when you do EVAL. Any other manipulation can be done as a symbolic, so why could someone need to see the algebraic as an RPN expression? to write your own CAS? In that case you'd use the object internals directly, RPN is not the best notation for a CAS, newRPL uses direct polish notation (like LISP, with the operator first so you know what you are doing before you process a bunch of arguments).
Find all posts by this user
Quote this message in a reply
01-16-2017, 04:39 PM (This post was last modified: 01-17-2017 11:59 AM by compsystems.)
Post: #7
RE: New RPL: New Commands
Hello Claudio

I use it for example in the input of a function.
"Enter algebraic expression in quotation marks" and then I transform into RPN, Since for many people entering an expression from a dialog box in RPN is not so simple. In RPN it is easier to do replacement and substitutions than in algebraic mode.

A command, even more important is the PART function, this always use it within my programs ..

The idea is that it is embedded within the language and not having to program it

Thread

PART function (TI89, HPPRIME) for HP48/49/50
http://www.hpmuseum.org/forum/thread-637...light=part

http://www.hpmuseum.org/forum/thread-650...light=part
Visit this user's website Find all posts by this user
Quote this message in a reply
01-17-2017, 02:26 PM
Post: #8
RE: New RPL: New Commands
(01-16-2017 04:39 PM)compsystems Wrote:  Hello Claudio

I use it for example in the input of a function.
"Enter algebraic expression in quotation marks" and then I transform into RPN, Since for many people entering an expression from a dialog box in RPN is not so simple. In RPN it is easier to do replacement and substitutions than in algebraic mode.

A command, even more important is the PART function, this always use it within my programs ..

The idea is that it is embedded within the language and not having to program it

Thread

PART function (TI89, HPPRIME) for HP48/49/50
http://www.hpmuseum.org/forum/thread-637...light=part

http://www.hpmuseum.org/forum/thread-650...light=part

Now we are talking: instead of asking for a command to implement the particular solution you chose, ask for a solution to the original problem. In this case, your problem are substitutions and replacements, not representing the expression as RPN (that's how you implemented a solution to the original problem, but not a problem by itself). There will be a rules engine (75% done but unfinished, so it's disabled for the time being) that will allow powerful substitutions using rules. You won't ever need to analyze the expression as RPN, just write the proper rules.

Regarding PARTS, it should be easy to implement, as it matches the internal representation of symbolics in newRPL.

Symbolics are stored as:
( Operator NumberOfArguments arg1 ... argN )

So getting the number of arguments, or extracting one of them is a trivial task.

On one hand, your use case of derivatives will be much better served by the rules engine (the rules engine is being written precisely to do derivatives and integrals based on tables of rules) so you won't really need PARTS, but being almost trivial to write I can include PARTS as a command in newRPL, might be useful for other things too.
Find all posts by this user
Quote this message in a reply
01-17-2017, 03:50 PM
Post: #9
RE: New RPL: New Commands
For sake of it name it OBJPARTS (or something) so there is still some 5 character long names free after all is done. Smile
Find all posts by this user
Quote this message in a reply
01-17-2017, 07:42 PM
Post: #10
RE: New RPL: New Commands
(01-17-2017 03:50 PM)Vtile Wrote:  For sake of it name it OBJPARTS (or something) so there is still some 5 character long names free after all is done. Smile

Fair request (perhaps SYMBPART). Most new commands being added have long names for that reason (or perhaps to make you addicted to autocomplete so you can't go back to stock ROM :-).
Find all posts by this user
Quote this message in a reply
01-19-2017, 07:06 AM (This post was last modified: 01-20-2017 12:31 AM by The Shadow.)
Post: #11
RE: New RPL: New Commands
I've been thinking of getting a spare 50g while they can still be had, and finding out about newRPL has pushed me over the edge. Smile Thanks for your hard work and that of your team, Claudio!

That said, I do have a bit of a wishlist and a few suggested tweaks.

I love that you fixed the bizarre behavior of (sum)LIST and (product)LIST on lists of size 1. How about also adding the mathematical conventions for such operations on empty lists? By convention, the empty sum is 0 and the empty product is 1. This will save a bit of error handling, notably when dealing with lists produced by FACTORS.

Speaking of FACTORS... I know the CAS is a ways off, but you're going to have to do it differently than in RPL. On the 50g, the primes are integers and the exponents are reals, which gives you a handle for differentiating them using MAP and DOLIST. That won't be the case in newRPL. I suggest implementing it as a list of lists, so 24 would become { { 2 3 } { 3 1 } }. Or possibly a list of complex numbers, { (2,3) (3,1) }, or even 2x1 vectors. Then, rather than treating units like -1 or i as factors, they could simply be stuck in the list as numbers - the different type would be sufficient to tell them apart from the others. 0 could also be treated this way, to spare us the absurdity of treating it as a factor.

EDIT: I just realized that complex numbers would give the nice ability to do RE or IM on the list as a whole, rather than having to do << 1 GET >> MAP or the like.

EDIT2: Actually, you know what? The best thing would just be to return three items, the unit (or 0), one list of factors and one of their exponents.

I would also dearly love to see commands to find the Hermite and Smith normal forms of a matrix!

Aesthetically speaking, I'd like to see most commands given names short enough to be differentiated in the menus. (Also, shouldn't the help tell us the name of the function, so we can tell them apart?)
Find all posts by this user
Quote this message in a reply
01-20-2017, 07:42 PM (This post was last modified: 01-20-2017 08:01 PM by The Shadow.)
Post: #12
RE: New RPL: New Commands
Also on the wish list: A built-in list subtraction command. (In the sense of set subtraction, not element by element.) I can certainly code it myself in RPL, but the faster the better!

A command to eliminate duplicate elements in a list. (Actually, the reverse POS command you mentioned elsewhere would make this much easier to code.)

List union and intersection would be nice too, but aren't as essential.
Find all posts by this user
Quote this message in a reply
01-20-2017, 11:47 PM
Post: #13
RE: New RPL: New Commands
(01-19-2017 07:06 AM)The Shadow Wrote:  I've been thinking of getting a spare 50g while they can still be had, and finding out about newRPL has pushed me over the edge. Smile Thanks for your hard work and that of your team, Claudio!

That said, I do have a bit of a wishlist and a few suggested tweaks.

I love that you fixed the bizarre behavior of (sum)LIST and (product)LIST on lists of size 1. How about also adding the mathematical conventions for such operations on empty lists? By convention, the empty sum is 0 and the empty product is 1. This will save a bit of error handling, notably when dealing with lists produced by FACTORS.

There was some discussion about this. The sum or the product are not necessarily 0 or 1. The main issue is that an empty list doesn't have a type of element, therefore how do you know the result is supposed to be a number?

{ "A" "B" "C" } \(\sum\)LIST --> "ABC"
{ } \(\sum\)LIST --> "" ???
or it could be a sum of vectors, or mxn matrices, etc. you get the point.

Given only an empty list there's no way for these commands to know what the result should be.
The easy solution is to always add the neutral element of the correct type. If you want 3x3 matrices:

{ ..list, possibly empty... } { [[1 0 0] [0 1 0] [0 0 1]] } + \(\prod\)LIST

(01-19-2017 07:06 AM)The Shadow Wrote:  Speaking of FACTORS... I know the CAS is a ways off, but you're going to have to do it differently than in RPL. On the 50g, the primes are integers and the exponents are reals, which gives you a handle for differentiating them using MAP and DOLIST. That won't be the case in newRPL. I suggest implementing it as a list of lists, so 24 would become { { 2 3 } { 3 1 } }. Or possibly a list of complex numbers, { (2,3) (3,1) }, or even 2x1 vectors. Then, rather than treating units like -1 or i as factors, they could simply be stuck in the list as numbers - the different type would be sufficient to tell them apart from the others. 0 could also be treated this way, to spare us the absurdity of treating it as a factor.

EDIT: I just realized that complex numbers would give the nice ability to do RE or IM on the list as a whole, rather than having to do << 1 GET >> MAP or the like.

EDIT2: Actually, you know what? The best thing would just be to return three items, the unit (or 0), one list of factors and one of their exponents.

It's a valid point. I'll mark these suggestions when the time comes to implement FACTORS.

(01-19-2017 07:06 AM)The Shadow Wrote:  I would also dearly love to see commands to find the Hermite and Smith normal forms of a matrix!

Aesthetically speaking, I'd like to see most commands given names short enough to be differentiated in the menus. (Also, shouldn't the help tell us the name of the function, so we can tell them apart?)
Yes, that's a change that's on the pipeline. There's now space to display the command name above the text of the help.
Regarding the matrix normals, I'll try to remember when it's time to complete all those missing commands in the matrix library.

(01-20-2017 07:42 PM)The Shadow Wrote:  Also on the wish list: A built-in list subtraction command. (In the sense of set subtraction, not element by element.) I can certainly code it myself in RPL, but the faster the better!

A command to eliminate duplicate elements in a list. (Actually, the reverse POS command you mentioned elsewhere would make this much easier to code.)

List union and intersection would be nice too, but aren't as essential.

Commands to use lists as sets are interesting, I'll also add them if there's room and time.
I'll add all your ideas to our bug tracker, so I don't forget.
Find all posts by this user
Quote this message in a reply
01-21-2017, 04:29 AM
Post: #14
RE: New RPL: New Commands
(01-20-2017 11:47 PM)Claudio L. Wrote:  The main issue is that an empty list doesn't have a type of element, therefore how do you know the result is supposed to be a number?


Oy. You're absolutely right, I didn't think of that.

Quote: Commands to use lists as sets are interesting, I'll also add them if there's room and time.


If there's only room for one, I'll take set subtraction, it's easy enough to build the others using it. Plus it has all sorts of uses in unrelated programming.

Quote:I'll add all your ideas to our bug tracker, so I don't forget.

Thanks so much! I'm wishing I'd gotten around to learning C so I could help!

I've been compiling the information about newRPL from bits and pieces in various threads, would you like me to write it up to be posted for new users?
Find all posts by this user
Quote this message in a reply
01-21-2017, 08:17 PM (This post was last modified: 01-21-2017 11:03 PM by The Shadow.)
Post: #15
RE: New RPL: New Commands
I've been pondering some more on list commands, and I think I've come up with a really useful one: LFREQ.

It takes a list L and returns two: A list of the unique elements in L, and a list of how many times each shows up in L.

Now LFREQ DROP will give the "eliminate duplicates" command I suggested earlier. Plus, of course, it has wider applicability.

Perhaps the reverse of LFREQ would also be useful: Take lists of elements and their frequencies and build a list. Call it LBUILD, maybe?

So say you want no element to appear more than twice. You just do LFREQ << IF DUP 2 > THEN DROP 2 END >> MAP LBUILD

Plus, if there's a particular element you want to eliminate, you just insert a 0 as its frequency.

EDIT: Using LFREQ on the columns of (sigma)DAT would also be useful. Doing LFREQ DUP << MAX >> STREAM POS GET would give you the mode, for example. (Though you'd have to get a little more complicated to deal with ties.)

EDIT: LBUILD could interpret negative frequencies as "Do INV if it makes sense for the object, then insert ABS(frequency) times." Useful when dealing with factors of rational numbers.

EDIT: LFREQ and LBUILD should play nicely with a new version of FACTORS, too, since the exponents are just the frequencies of the list of prime factors.
Find all posts by this user
Quote this message in a reply
01-22-2017, 01:53 AM
Post: #16
RE: New RPL: New Commands
(01-21-2017 04:29 AM)The Shadow Wrote:  I've been compiling the information about newRPL from bits and pieces in various threads, would you like me to write it up to be posted for new users?

All advocacy work is welcome, if you have any questions on undocumented details you'd like to document/understand you can send me a PM or an email so I can contribute to your work.
While I wrote quite a bit about the basics of newRPL (the official docs here), it's showing its age as I haven't been able to sit down and write for a long time.
Find all posts by this user
Quote this message in a reply
01-22-2017, 04:10 AM
Post: #17
RE: New RPL: New Commands
(01-22-2017 01:53 AM)Claudio L. Wrote:  
(01-21-2017 04:29 AM)The Shadow Wrote:  I've been compiling the information about newRPL from bits and pieces in various threads, would you like me to write it up to be posted for new users?

All advocacy work is welcome, if you have any questions on undocumented details you'd like to document/understand you can send me a PM or an email so I can contribute to your work.
While I wrote quite a bit about the basics of newRPL (the official docs here), it's showing its age as I haven't been able to sit down and write for a long time.

Gladly! If you'd be so good as to PM me your email address, I will probably indeed have some questions at some point.
Find all posts by this user
Quote this message in a reply
Post Reply 




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