3 ms·
After learning Forth years ago I became addicted to RPN and stack-based calculation, to the point where I wrote myself a calculator for Android that does just w
by lolinder 2y ago
After learning Forth years ago I became addicted to RPN and stack-based calculation, to the point where I wrote myself a calculator for Android that does just what I need it to (no existing calculators satisfied my Forth-like craving).
The really nice thing about stack based calculators that keeps me coming back to mine is that I can get all the numbers I'm working with down in one shot and then figure out which computations I'm applying in which order as a second step.
Until I tried RPN I never noticed how much mental bandwidth I was using shuffling numbers around in my head so I could input them into my calculator in the right order. With my stack calculator I just get all the numbers down and then swap and roll as needed to get the computation right. The number of times I've had to redo a computation because I started out wrong has been reduced to effectively zero, because I'm able to fully engage my math brain instead of juggling numbers at the same time.
- kragen 2y agoi'm running gforth under termux on android. i just ran a video game on it earlier tonight, this one i wrote last month do you have a screencast of your calculator's user interface? it sounds interesting!
- lolinder 2y agoI don't, but it's pretty simple: it looks like a regular calculator, but instead of having a single line for the number it has a line for building a number and then a scrolling text box that shows the stack [0]. There's an enter button that moves a number from the construction line to the stack, or you can hit any of the operation keys to implicitly use the under-construction number as the top of the stack. If no number is under construction it uses the top two numbers as the operands. Short tap on the stack swaps the top two stack items, long press rolls the top three. If I were doing it again I'd have long press roll the entire stack (top becomes bottom, the rest move up)—since it's all visible and I'm not programming it this would actually be more useful. [0] On my phone at the time I wrote it this box had room for three numbers before scrolling. Now it has 12...
- kragen 2y agoi see! given your forth comment, i'm sort of surprised you didn't have r> and >r keys to move numbers between the stacks i feel like on a multitouch screen we ought to be able to tap on numbers to roll them to the top of the stack
- lolinder 2y agoYeah, there are definitely things to improve, but it's good enough for my use! Keep in mind that the phone I wrote this for had a 3–4" screen—there was barely room for one three-item stack, and no room at all for a return stack even if I wanted one. Oh, yeah, what I'm calling Roll is actually Rot in Forth.
- kragen 2y agoi think for this kind of thing it makes sense to pop up a low-pass-filtered translucent numeric entry keyboard on top of the values being displayed, the way touchscreen controls for games like fortnite and minetest work (check out handcam streamer videos on youtube if you haven't seen this). then you can use the whole display to display the numbers you're working on, so a 3–4" screen (4000mm²?) can display dozens of numbers. maybe the numeric entry keyboard should only be open while you're holding down a numeric-entry button with your other thumb, but anyway it shouldn't occupy screen real estate; it should overlay screen real estate you called two different things 'roll'; one of them is indeed rot in forth but the other is depth 1- roll