RPL Update

Discussions about the RPL and RPL+ programming languages

RPL Update

Postby oliver » Wed Jan 19, 2011 3:05 am

The RPL implementation in MorphEngine is undergoing development, with the goals of a) re-creating most of the hp 50g calculator, and b) creating new abilities.

This thread is a kind of (b)log of recent activities related to progress toward the first goal.
Site Admin
Posts: 433
Joined: Sat May 01, 2010 2:11 pm

RPL in v1.3

Postby oliver » Wed Jan 19, 2011 3:34 am

v1.3 moved RPL in ND1 from the level of the HP-28S to the hp 50g:

- The language as implemented in hp 50g, is now fully implemented. "Language" means all constructs of RPL, not the full command set present in the 50g. Specifically, "@" and CASE and proper local variable STO-family support have been added.

- A byte code compiler has been added. Performance is ~400% greater than the interpreter in v1.2.8. Pure language construct execution speed is greater than an emulator on the same hardware. Combined with command speed advantages, MorphEngine is now the fastest platform for RPL code execution. We're not stopping here and are working on code-morphing RPL to JavaScript.

- The list processing commands have been added: DOLIST, DOSUBS, STREAM, MAP. Implemented natively, these perform at high speeds.

- Upon download, text containing RPL code formatted with translation characters (\<< for ≪, etc.) is now recognized and automatically translated into a proper RPL program.

- The ability to enter Lists with HP-syntax and execute them has been added. Similarly commands in Strings can now be executed.

- A number of 50g commands have been added, incl. SORT, REVLIST, NEXTPRIME, PREVPRIME, DIVIS, FACTORS, I->R, R->I, "GROB xxx" OBJ->, DUPDUP, UNROT, NIP, LASTARG, MODSTO, POWMOD, MSGBOX

- RPL+ commands have been added: (for arrays:) insert, remove, sort, reverse, rsort, shuffle, isSameType; (for numbers and parallel processing:) primes, loggamma, randomize

- Single-stepping of HALT'ed RPL is much improved, with stack display and more.
Site Admin
Posts: 433
Joined: Sat May 01, 2010 2:11 pm

RPL in 1.3.5

Postby oliver » Sun Apr 03, 2011 2:35 am

Further 50g compatibility improvements and a couple of custom type improvements.
See the release notes at http://forums.naivedesign.com/viewtopic.php?f=7&t=234.

For RPL, the biggest news is the introduction of RPL+. But also "normal" RPL is seeing further speed improvements.
The benchmarks reported at http://naivedesign.com/ND1/ND1_Reference__HP_Comparison.html have been updated.
Site Admin
Posts: 433
Joined: Sat May 01, 2010 2:11 pm

RPL in 1.3.8

Postby oliver » Fri May 20, 2011 1:36 pm

Continued command additions.

OBJ-> now complete, permitting "unpeeling" of expressions
POWMOD now more powerful than on 50g. Try: [[0 1][1 1]] 100000000000000 POWMOD
PEVAL added. Can be used to convert a polynomial from coefficients to symbolic expression representation.

The Poly shared folder was "ported" with minimal changes from HP 48. Together with PEVAL, symbolic manipulation of polynomials is now possible.

New shared folder Project Euler features most solutions written in RPL (or RPL+). These are apparently among the most compact written in any language.

RPL+ has its []-operator extended to strings.
Site Admin
Posts: 433
Joined: Sat May 01, 2010 2:11 pm

RPL in 1.3.9 and 1.3.10

Postby oliver » Thu Jan 05, 2012 4:09 pm

Additions included: ∫ (numerical integration), →DIAG, ΣLIST, ΠLIST, INCR, DECR.
The big feature of this update was Fractions. So, →Q was added too, along with a bunch of operator support for fractions and various constructors.

RPL+ added various new operators: =+, =*, etc.
Site Admin
Posts: 433
Joined: Sat May 01, 2010 2:11 pm

RPL in 1.4

Postby oliver » Thu Jan 05, 2012 5:03 pm

1.4 is a big update and includes a number of RPL backwards compatibility commands in its list of 50+ new commands.

Notably, polar and cylindrical coordinate systems are now supported, similar to the 50g. Set via the Mode menu, or, classic commands SPHERE, RECT, CYLIN, 2- and 3-component vectors, and complex numbers, are now displayed according to the coordinate system selected. This somewhat obsoletes the (28S-style) P→R and R→P commands, which remain nonetheless. (HP decided to remove them as they introduced the 48; we keep them for backwards compatibility.)

Other 50g commands added: REPL, IDIV2.

The classic 50g RPL language (not the command set) is complete, but receives two commands that many thought should have been there all along: BREAK, CONTINUE. Along with two commands that merge these commands with IF: IFTB (if-then-break), IFTC (if-then-continue). (Naming in the "spirit" of IFTE.)

The big majority of new commands are new ones, though, and, as such, not covered here. (See the 1.4 release notes.) Suffice to say that 20+ new array commands extend by some margin, what you can do with vector/lists/arrays in RPL. Many of the new commands take code fragments (in list, RPL program, or string form) as a parameter, and extend the family of list processing commands (which was already on the 50g level in ND1).

OBJ→ has been extended to custom data types. Those didn't exist on the 50g. This, then, is an example for how a classic command becomes extended beyond its traditional scope.

BigFloat and ContinuedFraction are data types that have been added, that have no 50g equivalents.

RPL+ is growing up fast. Hash-tables and immediate algebraic expressions have been added. Both are very easy to use.

Combined with the new list processing functions, a coding style is promoted that is shorter and more powerful than classic RPL (trading FOR-loops with array processing functions), but still reads like RPL.

Code: Select all
≪ 40e6 primes DUP
   { real phi } { real 1 == } doUntil
   { real 25-2 == } select

This (Project Euler problem) computes the sum of the primes below a certain limit, that produce chains of a certain length when applying the Euler totient (phi) function, until a value of 1 is reached.
doUntil applies one code fragment to each component of a list, until another code fragment, a condition, becomes true. As such, one simple keyword replaces a FOR-loop and a DO-UNTIL-loop. It returns two lists, for final iteration value and iteration count.
select picks those elements from one list for which the corresponding element in a second list returns true after applying a condition code fragment. (There's also a simpler array processing command, filter, that works like this for one list.)
Optional hints (the real word at the beginning of each code fragment, allow the compiler to optimize run-time performance. total is modern syntax for ∑LIST.
25-2 is post-fix notation thrown into this (via RPL+'s immediate algebraic expressions, which basically allows you to type expr when in RPL you had to type 'expr' EVAL), for enhanced readability.

Solving this task in traditional RPL would result in a much longer, harder to read program.

This trend is not going to go away with ND1/MorphEngine. We'll expend more effort to increasing the expressive power of RPL+ than to work on backwards compatibility.

Having said that, work on the CAS is in full swing and it will be fully oriented on the 50g CAS command set. An announcement about the CAS is due soon.
Site Admin
Posts: 433
Joined: Sat May 01, 2010 2:11 pm

Return to RPL / RPL+

Who is online

Users browsing this forum: No registered users and 1 guest