Earlier quoted context omitted.
That's interesting: commands that consume everything in the stack. About saving/loading words: I have plans to work on that, it could be a very useful feature.
Postscript had the concept of dropping a mark on the stack that allowed commands that would consume the whole stack to also stop at a mark if encountered. 5 4 mark 3 2 1 sum -> 5 4 6
Clac – A command-line, stack-based calculator with postfix notation
21–29 of 29 posts
Re: Clac – A command-line, stack-based calculator with postfix notation
#22I don't understand why things like this get posted to HN so often. This kind of program is a very common exercise in university courses and appears in countless programming books. Heck, you implemented it in C, and this exact exercise appears in K&R C. I hope this doesn't come off as snide... I just don't understand why the author would think this is something worth showing off.
Re: Clac – A command-line, stack-based calculator with postfix notation
#23For those not familiar with "dc", try running dc and then running "7 100 ^ p". Arbitrary precision! One of the reasons dc doesn't print things out is so you can use it to do arithmetic in your shell scripts.
you can use $((5+5)) if you want to do arithmetic in a bash shell. Most of the time that's all that's needed.
It was written in B before the C programming language was created.
Re: Clac – A command-line, stack-based calculator with postfix notation
#24I don't understand why things like this get posted to HN so often. This kind of program is a very common exercise in university courses and appears in countless programming books. Heck, you implemented it in C, and this exact exercise appears in K&R C. I hope this doesn't come off as snide... I just don't understand why the author would think this is something worth showing off.
Re: Clac – A command-line, stack-based calculator with postfix notation
#25Unfortunately, the homepage seems to be down at the moment, but here's a freecode link. It's also packaged for most popular distros.
Re: Clac – A command-line, stack-based calculator with postfix notation
#26Surprisingly, postfix calculators fell out of fashion. I still have an original HP-11C on my desk. Students are now introduced to calculators that meet the "educational standard", that is, the TI-84 and its approved clones. That seems to have set what people expect in a calculator.
Re: Clac – A command-line, stack-based calculator with postfix notation
#27On a side note, the description of arithmetic says that - and / swap the inputs, and it describes the operators as popping values a and b (and in the case of swap, then pushing a and b back on). This is a little confusing. It would be much simpler just to say that all binary operators pop values b and a. Now you don't have to swap anything, because - and / will still just perform a - b and a / b. And the fact that this swaps + and * is irrelevant, because those operators are commutative. And the swap operator makes more sense, because it "pops values b and a, and pushes values a and b", so you can now actually see the swapped values in the description.
Re: Clac – A command-line, stack-based calculator with postfix notation
#28Surprisingly, postfix calculators fell out of fashion. I still have an original HP-11C on my desk. Students are now introduced to calculators that meet the "educational standard", that is, the TI-84 and its approved clones. That seems to have set what people expect in a calculator.
There is a great HP-41C for iOS: i41Cx. I believe it's the most expensive app I have, and it's worth every penny. I still have my HP-41, but I never drag it out because of this.
I use Free42 for iOS and it works beautifully. Plus I can leave my real 42s safe in a drawer at home.
https://itunes.apple.com/us/app/free42/id337692629
There are other builds for Android, Windows, Mac, and Linux:
Re: Clac – A command-line, stack-based calculator with postfix notation
#29Earlier quoted context omitted.
I just want to say great work. The parent comment here didn't realize that you drastically improved the user experience by showing the stack, which I think makes all the difference here. To make this clear, I would upload your video to gfycat and link the gif in your readme.
I just updated the README with a gif of that video. Thanks for the idea!
You guys are right, I didn't realise it was this cool, and I was too quick to be cynical.