TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Clac – A command-line, stack-based calculator with postfix notation

75 点作者 djanowski大约 8 年前

9 条评论

klodolph大约 8 年前
For 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.
评论 #14110396 未加载
protomyth大约 8 年前
Nice. I did one in Perl a long while back. I added <i>sum</i> to sum the contents of the stack (good for bill paying day) and <i>pt</i> for Pythagorean theorem because I was doing a lot of cable distances.<p>Is there a command line Forth interpreter out there that can save words or load a startup dictionary each use?
评论 #14109567 未加载
eridius大约 8 年前
When I saw the headline, I wondered what was so special about this. But actually reading the description, the UI sounds like a significant improvement in usability, such that I might actually consider using a postfix calculator like this.<p>On a side note, the description of arithmetic says that - and &#x2F; 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&#x27;t have to swap anything, because - and &#x2F; will still just perform a - b and a &#x2F; b. And the fact that this swaps + and * is irrelevant, because those operators are commutative. And the swap operator makes more sense, because it &quot;pops values b and a, and pushes values a and b&quot;, so you can now actually see the swapped values in the description.
auxym大约 8 年前
orpie has been my main calculator-on-the-pc for a while now. Curses based interface, written in OCaml, extensive library of scientific functions, configurable hotkeys. It&#x27;s quite neat.<p>Unfortunately, the homepage seems to be down at the moment, but here&#x27;s a freecode link. It&#x27;s also packaged for most popular distros.<p><a href="http:&#x2F;&#x2F;freecode.com&#x2F;projects&#x2F;orpie" rel="nofollow">http:&#x2F;&#x2F;freecode.com&#x2F;projects&#x2F;orpie</a>
Animats大约 8 年前
Surprisingly, 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 &quot;educational standard&quot;, that is, the TI-84 and its approved clones. That seems to have set what people expect in a calculator.
评论 #14111538 未加载
GilbertErik大约 8 年前
If I need to see what&#x27;s going on, I&#x27;ve relied on orpie for quite a long time. I like soveran&#x27;s video showing off what it does, but I&#x27;d rather manipulate a stack rather than have the output appended to the end of my cursor.
Kametrixom大约 8 年前
There is also bc [1] which isn&#x27;t stack based and pretty standard. See [2] for a discussion on dc vs bc.<p>[1]: <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Bc_(programming_language)" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Bc_(programming_language)</a><p>[2]: <a href="https:&#x2F;&#x2F;unix.stackexchange.com&#x2F;questions&#x2F;124518&#x2F;how-is-bc-different-from-dc" rel="nofollow">https:&#x2F;&#x2F;unix.stackexchange.com&#x2F;questions&#x2F;124518&#x2F;how-is-bc-di...</a>
pkd大约 8 年前
I did this as part of my data structures course at University! Good exercise, but obviously mine lacked the swap, dup features etc. Instead I had min and max implemented.
lexpar大约 8 年前
I don&#x27;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&amp;R C.<p>I hope this doesn&#x27;t come off as snide... I just don&#x27;t understand why the author would think this is something worth showing off.
评论 #14109466 未加载
评论 #14110967 未加载
评论 #14111385 未加载
评论 #14109345 未加载
评论 #14109392 未加载
评论 #14109259 未加载
评论 #14109519 未加载