RPL+

Discussions about the RPL and RPL+ programming languages

Immediate algebraic expressions

Postby oliver » Fri Nov 18, 2011 4:44 am

The latest feature of RPL+ is simple, but radical, with big implication on the code that can be written:
Instead of
Code: Select all
'expr' EVAL
you'll be able to write
Code: Select all
expr


That is, algebraic expressions are allowed without special decoration, and will be evaluated automatically.
This permits you to mix and match infix and postfix notations.

For example, you may write
Code: Select all
1 3+4-x FOR i
instead of
Code: Select all
1 3 4 + x - FOR i

or
Code: Select all
sin(a)
instead of
Code: Select all
a sin

or
Code: Select all
IF total(divs(x))==5 THEN … END
instead of
Code: Select all
IF x divs total 5 == THEN … END


There's one requirement: the algebraic expression may not contain white space characters (space, tab, newline).
oliver
Site Admin
 
Posts: 433
Joined: Sat May 01, 2010 2:11 pm

Rec1: Support for JSON Objects

Postby oliver » Mon Aug 13, 2012 2:36 am

RPL on ND1 has always had the ability to code literal JS Objects. This could be used by users to interface with JavaScript code that took objects as an input argument, and is, along with arrays, the only other way to pass a variable number of arguments into a function. The ability sees its first use with a built-in command now: the WAopt command, used to shape Wolfram|Alpha queries (http://forums.naivedesign.com/viewtopic.php?f=11&t=673).

Examples:
Code: Select all
'x^2' "D[" {"pod": "Input" } WAopt
"San Francisco" "population" {"expr": true, "erase": /.people.+/ } WAopt


I do not want to preclude that RPL+ could be ported and used on different calculators, so not every feature in ND1's implementation has been pulled into this RPL+ language description. This particular one is somewhat specific to JavaScript being available as receiving language (although JSON is a data format in widespread use and exists mainly outside of the context of JavaScript), and could be hard to implement. Thus, it is not made an "official" RPL+ language feature.

While these notes are not a formal language specification, I'd like to give visibility to this feature at this point and make it a first recommended, yet optional, feature that an RPL+ implementation may support.

Recommendation 1: It is recommended that an RPL+ implementation supports literal object definitions following the JSON syntax. (http://www.json.org/)
oliver
Site Admin
 
Posts: 433
Joined: Sat May 01, 2010 2:11 pm

Previous

Return to RPL / RPL+

Who is online

Users browsing this forum: No registered users and 1 guest

cron