newRPL: symbolic numbers
12-29-2014, 03:19 PM
Post: #14
 Claudio L. Senior Member Posts: 1,883 Joined: Dec 2013
RE: newRPL: symbolic numbers
(12-24-2014 07:51 PM)Claudio L. Wrote:  * Forget about quoted numbers.

Actually, I'd like to take that back.

Quote:The idea would be something like this:
{ 1 2 3 4 5 } '2' / would return { '1/2' '2/2' '3/2' '4/2' '5/2' }
{ 45 '45' } SIN would return { 0.707... 'SIN(45)' }
2 INV --> 0.5
'2' INV --> '1/2'

So quoted numbers will exist, alongside the trailing dot:

{ 45 45. '45' '45.' } SIN
will return {0.707... 0.707... 'SIN(45)' 'SIN(45.)' }
and after EVAL, {0.707... 0.707... 'SIN(45)' 0.707... }

Also, I think the trailing dot concept could also be extended to variable identifiers and constants.
For example, typing:
π will leave the symbolic constant π on the stack.
But typing π. (with the dot) should leave 3.1415.... on the stack.

Same thing for variables. If the variable name is followed by a dot, it is interpreted as an approximated expression, and upon evaluation, it's numeric value will be calculated and returned, as if ->NUM was executed.
For example:
2 'X' STO
'X^2' 'Y' STO

Now, typing
Y will leave 'X^2' on the stack.
Y. will leave 4 on the stack.

'Y+1' EVAL will leave 'X^2+1' and another EVAL will produce the number 5.
'Y.+1' EVAL will produce '4+1' and another EVAL the number 5.

Note: The need for multiple EVAL's is because as of now newRPL CAS doesn't do recursive substitutions (the 50g would show the number 5 on the first EVAL). Perhaps a command EVALALL will be added, or perhaps EVAL will behave like the 50g, and a new command like EVAL1 will do a non-recursive single-step as shown above, this is still in the works and subject to change.