clcs is a simple command line calculator with limited functionality.
The logic is fully contained within clcs.js that can be reused at will. However, it does not contain any quality of life features, only code that is necessary for executing these calculations and storing the last result (as reusing its value is part of the "notation" itself).
clcs uses a modified version of Polish Notation (PN), sometimes called Zolish Notation (ZN); think of it as "lisp without the outermost and sometimes implied parentheses".
Operators are followed by a number of operands (as opposed to PN where there is always two). This means, that nested expressions must be enclosed by parentheses, otherwise all of the remaining operands would be considered part of the inner expression. For example,
+ 1 2 - 3 4 5 6
is equivalent to
1 + 2 + (3 - 4 - 5 - 6)
and
+ 1 2 (- 3 4) 5 6
is equivalent to
1 + 2 + (3 - 4) + 5 + 6
.
As a limitation of clcs's implementation, nested parentheses are currently not supported, hence your inner expressions cannot themselves have inner expressions inside. For example
+ 1 2 (- 3 (* 2 2)) 5 6
is not a valid expression in clcs, but is would be valid in general ZN and would be the same as
1 + 2 + (3 - (2 * 2)) + 5 + 6
.
While not a mandatory part of ZN, operand-inference is a recommended practice and part of the clcs implementation; if only one operand is provided, the result of the previous operation should be used as the expression's first operand. For example if we do the following calculations:
+ 1 2
- 4
+ 2
the result should be 1
. The first operand in the second and third operation is inferred to be ans
, which is the conventional name of the previous result:
+ 1 2 (=> 3)
- ans 4 (=> -1)
+ ans 2 (=> 1)
However, when ans
is explicitly given in an expression, it will be first evaluated to mean the last expression's result and will not be updated to the last calculation's result. For example, if the last result was 0
, then the evaluation would go like this:
+ (- 1 1) 0
- 1 1 (=> 0)
+ 0 0 (=> 0)
0
+ - (* 2 5) + ans 6
* 2 5 (=> 10)
+ 0 6 (=> 6)
- 10 6 (=> 4)
+ 4 4 (=> 8)
8
and not:
+ (- 1 1) 0
- 1 1 (=> 0)
+ 0 0 (=> 0)
0
+ - (* 2 5) + 6
* 2 5 (=> 10)
+ 10 6 (=> 16)
- 10 16 (=> -6)
+ -6 -6 (=> -12)
-12
The following operations are available:
+
: Addition-
: Subtraction*
: Multiplication/
: Division\
: Integer division^
: Exponentiation%
: Modulor
: Random number
The following constants and values are available:
pi
: πe
: eans
: result of last expression ("answer")
A legend for additional functions is available by pressing Esc
. Most functions are available by pressing Alt
and various keys.
Various color schemes are available:
Copyright © 2025 ae-dschorsaanjo
This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See the LICENSE file for more details.
The ANAKRON font is licensed under the OFL-1.1 license.