RPL mini-challenge - Triangle of Primes (HP-49G/G+,50g)
|
07-04-2019, 08:21 PM
(This post was last modified: 07-04-2019 09:50 PM by DavidM.)
Post: #23
|
|||
|
|||
RE: RPL mini-challenge - Triangle of Primes (HP-49G/G+,50g)
(07-04-2019 03:17 AM)Gerson W. Barbosa Wrote: ... Let’s see how far this goes :-) Be careful what you ask for! Inspired by Gerson's program and Claudio's optimizations, I thought I'd try to transcode that version into SysRPL to see how it might turn out. This version does accommodate both exact and approximate numbers for input. Due to the looping being based on BINTs, it has a maximum input value of 1048575. You are far more patient than me if you want to try values higher than a few hundred, even on emulated systems! Several command sequences in this algorithm align nicely with SysRPL "combo" commands (combinations of several commands into one opcode), so the program size decreased accordingly to 52 bytes. The SysRPL loop code executes slightly faster than the UserRPL equivalent, and the final runtime shows that as well: about 360 seconds on my 50g for an input of 99. To try this out on a 50g, make sure you have a suitable extable installed (this one should do), then execute: 256 ATTACH This will make the built-in development tools available. Next, place the following code on the stack as a string: Code: !NO CODE To compile the above code into executable form, simply execute ASM. This will create the program object on the stack, which can then be saved to a global variable or executed directly from the stack with EVAL (don't forget the needed argument, which should be added to the stack prior to execution). Compiling the code does require the extable to be installed first, of course, but the program itself uses only built-in commands. Thanks for the mini-challenge, Gerson! |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)