RPL equivalents to BREAK, CYCLE, EXIT, etc.?
|
06-09-2014, 07:43 PM
Post: #20
|
|||
|
|||
RE: RPL equivalents to BREAK, CYCLE, EXIT, etc.?
(06-09-2014 04:24 PM)DavidM Wrote: Before I even responded to Thomas, I realized that he intentionally chose an example that was biased toward using something like a BREAK. My intention was to provide an example where eliminating the BREAK isn't trivial. I knew you couldn't use the FOR-loop and then you had to find a way to access the outcome of hasDivisor outside the loop. Throwing an error allows to pass that information without using a local variable. I guess the most difficult part in my program is to figure out the next step after DROP: Code: NEXT DROP And I agree with you: reasoning about a program is more difficult if there are multiple exit points. I like your solution: By using meaningful names for the variables the intent is made clear. Let me add a 3rd more functional variant: Code: \<< \-> n Kind regards Thomas |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)