Post Reply 
newRPL: Alpha demo 0.9 released [UPDATED 2017-10-25]
10-25-2017, 01:15 AM
Post: #197
RE: newRPL: Alpha demo 0.9 released [UPDATED 2017-09-15]
(10-24-2017 05:57 PM)The Shadow Wrote:  
(10-24-2017 04:57 PM)Gilles59 Wrote:  PI ( LS SPC ) NUM-> return "Undefined variable"
Stock HP50G returns 3.14....

At present, pi is implemented as a command pi0. (Greek letter pi followed by zero.) My understanding is that this will change at some point.

Constants are not implemented yet (complex i, pi, e, and a few others). The implemented pi0 is not a constant, in the sense that it cannot be used in a symbolic expression. It's a command (temporary), which returns pi with twice the system precision.

(10-24-2017 11:38 PM)Gilles59 Wrote:  Difference between UserRPL an NewRPL :

In UserRPL :
1 { 2 2 + } IFT
returns 4

In NewRPL
1 {2 2 + } IFT
returns {2 2 +}

I guess its because UserRPL eval the list with IFT (wich doesnt seem very logic in fact...).

This is indeed a difference between newRPL and userRPL, and is deliberate. userRPL only has EVAL, so it does just that, but it has the bad habit of executing lists as programs. I don't agree with that, I think if you put a list on the stack is because you want to return a list, otherwise you would've put a program.
newRPL has 3 different evaluation functions: XEQ, EVAL and EVAL1. EVAL is for the most part identical to userRPL. EVAL does evaluation, and for lists it only makes sense to EVAL each element of the list (like all other operators, it is passed straight to the elements in the list). The behavior of executing the list as a program always seemed out of place to me.
EVAL1 is similar to EVAL but doesn't recurse the evaluation of symbolics. It only evaluates one level, allowing recursion formulas to work:

'X+1' 'X' STO

Then doing 'X' EVAL1 will return 'X+1', another EVAL1 will become 'X+2', etc. In this case, EVAL would complain of circular reference.

Finally, XEQ is short for execute. For most objects, XEQting them means they just push themselves to the stack. Programs of course get executed (this is the main purpose of XEQ) but other objects like lists and symbolics are left untouched.
As you may have guessed, IFT doesn't do EVAL but XEQ in newRPL, so a program will get executed, but lists/symbolics remain as they are in the stack.
Depending on what you are doing, you may need to add an EVAL after IFT if you are porting code from userRPL.
For example:

'X+1' 'X<4' 'X*2' 'X^2' IFTE +

On userRPL, IFTE would EVAL 'X*2' or 'X^2', so if X is 3, it would return 'X+1+6'.
On newRPL, IFTE would do ISTRUE('X<4') and then XEQ('X*2') so in the same case it would return 'X+1+X*2'. It's not better or worse, just different.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: newRPL: Alpha demo 0.9 released [UPDATED 2017-09-15] - Claudio L. - 10-25-2017 01:15 AM



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