Now I want to see the competing entries in Java and Haskell. I especially want to know how I could have saved more space in Java. It's probably the number input - I parsed a command-line parameter using Integer.parseInt.
Also:
SysRPL
Rank | User | Size | Date |
1 | 3298 | 59.5 (don't ask me why; I'm going off of what he said) | 7/31/2014 5:18:48 PM |
That half-byte comes from the 4-bit processor SysRPL is designed for. Many things there have odd sizes, and when you have an odd number of nibbles, you get ... you guessed it, half bytes.
In case anyone wants to check it, you'll need to set up an emulator and install a development tool on it. The remaining part of the post is a tutorial for that.
A ready-to-use emulator comes with the free Windows-based IDE Debug4x (get it at
http://www.debug4x.com/). The emulator is in the subdirectory "Emu" of the installation directory. Start it, and it will ask for a KML script. This defines the look of the emulator, the key positions, and a few other things. The pre-installed KML script "Eric's Real 50G" should do the trick. I don't know whether the emulator only shows the screen afterwards (haven't used it in a while), but if it does, search the menus at the top for the option to show the entire calculator. The first step with the calculator should be to switch it to RPN mode (answer the "Try to recover memory?" question with No (the F6 key), confirm the "Memory cleared" message with ENTER, press the MODE key, then the +/- key, and finally the ENTER key).
Next step: SysRPL development stuff. The compiler is already installed, you just have to unlock it. But you need something providing the names of commands, otherwise you can only use UserRPL commands or nameless pointers. A library providing the names is called "extable". I'm using the one from
http://www.hpcalc.org/details.php?id=3940 (there is a file called "extable2.lib" in that archive, that's the right one). Drag the file into the emulator's screen, and something should appear behind the "1:". You just put the library on the stack. Now push the 0 and press ENTER. The library shifts up to level 2 of the stack, and the 0 appears on level 1. Now press the STO key. The stack should be empty now. Press and hold (this is done by right-clicking on the button instead of left-clicking) the ON key, and push C. This reboots the calculator and finishes the library installation. Now, unlock the compiler. Enter this without the quotes: "256 ATTACH". Don't forget to press the ENTER key at the end to execute the command. (Edit: I forgot to mention that you need to know how to enter the space here. In the bottom row you find a key labeled SPC, that's the space key.)
Now everything is set up. For ease of use, start the text editor this way: Put an empty string on the stack (the double quotes you need for that are present as a shifted function of the multiplication key), then press the down arrow. Enter the source code I gave you (Alpha-lock can be done with two presses on the Alpha key, a third press disables Alpha mode again). If you are missing a few special characters, use the char browser (CHARS is a shifted function of a key in the fourth row; be sure to disable alpha-lock before). Due to some weird requirement from the compiler, the last two chars must be a newline and an @ char, so add these. ENTER exits the editor and replaces the empty string on the stack with the contents of the editor. If you need to edit it again, the down arrow key puts you back in the editor.
Now we compile the source. Simply issue the ASM command with the source on stack level 1. If there are no errors, the source will be replaced by the compiled code (which looks like "FlashPtr External External ..." - that's perfectly normal). With the compiled code on level 1, you can check its size with the BYTES command (takes any object on level 1, gives a checksum on level 2 and the size in bytes on level 1). Or you can give it a parameter (enter the number on the stack, followed by the SWAP command to put it above the program) and run the program with the EVAL key. If you want to do both, these commands are helpful: DUP pushes a duplicate of level 1 (use this to avoid having to enter the source twice), DROP drops level 1, and CLEAR drops everything.
Be extra careful when running the program, no parameters or parameters of the wrong type will crash the calculator because I omitted the necessary checks for that. The input number must be an infinite-precision integer in this case, which is printed and entered as simply a number. Real numbers have a period somewhere, and they are not accepted.