This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
xrpl:rpl_language_overview [2019/05/05 15:05] – Added in-fix nototation via MPLLang translator added stub, changed heading levels Karsten75 | xrpl:rpl_language_overview [2019/12/02 09:14] – Karsten75 | ||
---|---|---|---|
Line 8: | Line 8: | ||
When we talk about common aspects of all the languages, it's easiest to write xRPL where the " | When we talk about common aspects of all the languages, it's easiest to write xRPL where the " | ||
- | xRPL programming is similar to programming a HP calculator or Forth language programming. If this is not something you have done, read on for a brief introduction to xRPL and stack-based programming. <wrap info>For a more detailed CRPL explanation, | + | xRPL programming is similar to programming a HP calculator or Forth language programming. If this is not something you have done, read on for a brief introduction to xRPL and stack-based programming. <wrap info>For a more detailed CRPL explanation, |
An xRPL instruction either use arguments (data) that is on a " | An xRPL instruction either use arguments (data) that is on a " | ||
Line 115: | Line 115: | ||
Both the above statements assign 7 to the variable " | Both the above statements assign 7 to the variable " | ||
+ | ==== Symbol Aliasing ==== | ||
+ | |||
+ | Many arithmetic operators | ||
+ | |||
+ | ^ Operator ^ Symbol ^ | ||
+ | | ADD | + | | ||
+ | | SUB | - | | ||
+ | | MUL | * | | ||
+ | | DIV | / | | ||
+ | | MOD | % | | ||
+ | | AND | && | | ||
+ | | OR | %%||%% | | ||
+ | | NOT | ! | | ||
+ | | POW | %%^%% | | ||
+ | | GT | > | | ||
+ | | GTE | > | ||
+ | | LT | < | | ||
+ | | LTE | <= | | ||
+ | | EQ | == | | ||
+ | | NEQ | != | | ||
+ | |||
==== Code translator ==== | ==== Code translator ==== | ||
- | [[https:// | + | [[https:// |
+ | |||
+ | For those struggling to master xRPL's post-fix format, this may be a useful tool. It can be obtained from [[https:// | ||
+ | |||
+ | Here are some sample translations, | ||
+ | |||
+ | <WRAP group> | ||
+ | <WRAP half column> | ||
+ | **mplLang code** | ||
+ | <code c> | ||
+ | x = 2 + 2 * 2; | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP half column> | ||
+ | **xRPL translated code** | ||
+ | <code 4rpl> | ||
+ | 2 2 2 mul add ->x | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | <WRAP group> | ||
+ | <WRAP half column> | ||
+ | <code c> | ||
+ | z = f(x, y); | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP half column> | ||
+ | <code 4rpl> | ||
+ | z = f(x, y); | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | <WRAP group> | ||
+ | <WRAP half column> | ||
+ | <code c> | ||
+ | [x, y] = CurrentCoords(); | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP half column> | ||
+ | <code 4rpl> | ||
+ | CurrentCoords ->y ->x | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | <WRAP group> | ||
+ | <WRAP half column> | ||
+ | <code c> | ||
+ | if(a<b && (c+1 == -c)) [a, b, c] = 1, 2.0, 3.14; | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP half column> | ||
+ | <code 4rpl> | ||
+ | <-a <-b lt <-c 1 add <-c neg eq and if | ||
+ | 1 2 3.140000 ->c ->b ->a | ||
+ | endif | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | <WRAP group> | ||
+ | <WRAP half column> | ||
+ | <code c> | ||
+ | do (1 .. 42){ | ||
+ | a = refRead(" | ||
+ | refWrite(7*(3.14+i), | ||
+ | } | ||
+ | </ | ||
+ | </ | ||
+ | <WRAP half column> | ||
+ | <code 4rpl> | ||
+ | 42 1 do | ||
+ | " | ||
+ | 7 3.140000 i add mul " | ||
+ | loop | ||
+ | </ | ||
+ | </ | ||
+ | </ |