hoc is a simple desk calculator, using yacc(1). This version of hoc is slightly modified from the one found in The Unix Programming Environment, by Brian Kernighan and Rob Pike (Addison-Wesley, 1984).
Changes since the book version:
-
The variable "_" contains the result of the last top-level expression evaluation, so you can re-use intermediate values without re-typing them.
-
for statement added, like the one in C, except that components may not be empty.
-
++ and — added, but don’t work with $i.
-
Interrupts are caught; use cntrl-D to quit.
-
% operator added.
-
+=, -=, etc., added.
-
\ at end of line eats newline.
-
results are 15 digits but variable PREC can be used to override this.
-
tabs on output are no longer.
-
asin, acos, sinh, cosh, tanh, erf, erfc