The named files are read and interpreted in order. If no file is given or if file is .L - hoc interprets the standard input. The -e option allows input to hoc to be specified on the command line, to be treated as if it appeared in a file.
Hoc input consists of expressions and statements . Expressions are evaluated and their results printed. Statements, typically assignments and function or procedure definitions, produce no output unless they explicitly call print .
Variable names have the usual syntax, including .LR _ ; the name .L _ by itself contains the value of the last expression evaluated. The variables E , PI , PHI , GAMMA and DEG are predefined; the last is 59.25..., degrees per radian.
Expressions are formed with these C-like operators, listed by decreasing precedence.
^ exponentiation
! - ++ --
* / %
+ -
> >= < <= == !=
&&
||
= += -= *= /= %=
Built in functions are abs , acos , asin , atan (one argument), cos , cosh , exp , int , log , log10 , sin , sinh , sqrt , tan , and tanh . The function read(x) reads a value into the variable x and returns 0 at EOF; the statement print prints a list of expressions that may include string constants such as \fL"hello\en"\f1.
Control flow statements are if - else , while , and for , with braces for grouping. Newline ends a statement. Backslash-newline is equivalent to a space.
Functions and procedures are introduced by the words func and proc ; return is used to return with a value from a function.
B. W. Kernighan and R. Pike, The Unix Programming Environment, Prentice-Hall, 1984