clcs is out now!
2025. 08. 31. 21:17 | \programming \random
Ever since ca. 2018 I had a dream of writing a command line calculator using my own notation. Obviously that didn't happen, so we have clcs instead.
For a quick demo, maybe start with the video "announcement", then hop over to the live website (which is just running on GitHub Pages):
So what is this exactly?
The simplest way I can put it is "basically Lisp without the outermost parentheses" or "an extension of (the regular) Polish Notation where you aren't limited to only 2 operands per operation".
What does it have?
The basic operations you would expect, +
addition, -
multiplication, *
multiplication, /
division, %
modulo, \
integer division, ^
exponentiation and r
random (integer) number generation.
+ 2 3 => 5
- 2 3 => -1
* 2 3 => 6
/ 2 3 => 0.667
% 2 3 => 2
\ 2 3 => 0
^ 2 3 => 8
r 2 3 => 2 or 3
You can also use parentheses to nest calculations, but only 2 levels deep.
+ (- 1 1) 2 => 2
The results of each operation (not expression!) is set to a special result value, which can be used implicitly if only one operand is given:
+ 1 2 => 3
- 1 => 2
This was implemented and is considered part of this "notation" due to how often you just want to manipulate the last result by adding to it, multiplying it, etc.
Update!
Now it has a verbose mode!
Press Alt+v
to enable it and a step-by-step breakdown will be available for every calculation.
What does it not have?
Nested parentheses are not allowed. This is because you should be able to write the operations/expressions in a way that they would be not necessary. It is also a lot harder to implement since JavaScript cannot handle recursive regular expressions -- this matters because it was written using vanilla JavaScript without any external libraries.
Sorry if it sounds like bragging, it really is not; it's just a matter of fact.
+ 1 (+ 2 3 (- 4 5) 6) 7 => ERROR
+ 1 (+ 2 3 6 - 4 5) 7 => 18
It also doesn't have a way to explicitly set the result, a.k.a. the answer. For that, you can use various expressions that first sets it to 0, then assigns a new variable. One such way is + (- 1 1) 2
where the - 1 1
will set the result to 0
and the rightmost number will be set to it next (by adding it to 0
).
The GUI
The GUI is not strictly speaking part of clcs, its is more like a reference implementation of how I would want to use it. It offers multiple functions such as an input history where you can recall previous inputs (although each stored input is unique), various color schemes, etc. These can be accessed by various keyboard commands that are outlined in the help (accessed by Esc
).
Why WTFPL?
It is under Do What The Fuck You Want Public License 2.0 because you can do whatever the fuck you want with it.
Any plans to further work on this?
Possibly, but not really. I have another (technically two other) "calculators" I began writing using a very different syntax. One of them is also in JS and would be the "Lite" version, the other is a larger Python project that seen quite a lot of work, but at the end I might end up rewriting the whole thing, including its specification.
This two versions are not compatible with one another and the JS version began as a coding exercise to see how much could I simplify the concept and implementation. Based on that experience, a complete reevaluation will be in order.
This project, clcs, also began as such an exercise, but using a different notation and a much smaller scope compared to either of those.
Zolish Notation? Really?
Yes, this is called Zolish Notation, because it's my "zoli-sh" way of the Polish Notation. What of it?
Why is this post formatted like a badly written FAQ?
Idk, it just turned out this way.
< Character sheet (for what?) | [comic] I'M BACK >