RPL second impressions (HP 28)
|
06-27-2018, 03:41 AM
(This post was last modified: 06-27-2018 03:42 AM by Joe Horn.)
Post: #5
|
|||
|
|||
RE: RPL second impressions (HP 28)
EDIT: Oops... I see that while I was writing the following DavidM beat me to it!
Ah, the joys of learning RPL! Welcome to the club! (06-27-2018 01:19 AM)mdunn Wrote: 3. Wonder if IF..THENs can be nested... Yes. See the Advanced Users Reference Manual, page 2-25 (that's one page, not a range) for an example of nested conditionals. RPL allows everything (*) to be nested as many levels deep as you want, limited only by its available memory and your available patience. A fun example is the →RPN program on page 2-28, which has an IF/THEN nested inside a FOR/NEXT loop which is nested inside an IF/THEN! * Gentle Reader: If there's anything that RPL doesn't allow to be nested, please correct me. Fleeting thought: Some nested IF/THEN structures are more efficiently coded (and more human-readable) using the CASE structure instead. (06-27-2018 01:19 AM)mdunn Wrote: 4. I find the multiple ways of writing things a tad confusing (RPN, algebraic, etc?). Since THEN treats 0 as false and any nonzero value as true, you can replace 0 == with just NOT in all of the above (e.g. IF a b / FP NOT THEN ... END), which makes the code slightly shorter and faster but cryptic to any human reader who doesn't know how THEN works. (06-27-2018 01:19 AM)mdunn Wrote: Algebraic: As the AUR mentions on pages 1-13 and 3-112, "If the test-clause is an algebraic, it’s automatically evaluated to a number — you don’t need →NUM or EVAL." Therefore IF 'FP(a/b)==0' THEN ... END and IF 'NOT FP(a/b)' THEN ... END also work (with the EVAL omitted). <0|ɸ|0> -Joe- |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)