RPL second impressions (HP 28)
|
06-30-2018, 01:20 AM
Post: #24
|
|||
|
|||
RE: RPL second impressions (HP 28)
(06-29-2018 07:14 PM)Thomas Okken Wrote: You still have to expend way too much mental energy to keep track of what is where in the stack. Instead of 3 values only one is permanently on the stack. It's the divisor that is incremented by 2 with each step in the DO-loop: Code: 2 + You may call it d or if you prefer OVER. Quote:"r OVER < OVER n SWAP MOD NOT OR" is only "easy to read" for very specific values of "easy." There's a reason I wrote this as: Code: r OVER < Using the variable d instead that would be: Code: r d < That's the combination of two predicates using or. In Python that would be: Code: r < d or n % d == 0 So there's left only one relevant stack operation: SWAP. In Forth we would probably factor this as: Code: : DIVIDES SWAP MOD NOT ; This would lead to: Code: r d < While we could extract that in UserRPL as code object in a local variable we'd still have to EVAL it. That's the reason I would avoid that. And then I assume it would be slow. Hopefully I reduced the mental energy needed to read that piece of code once more. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)