*** UNIX MANUAL PAGE BROWSER ***

A Nergahak database for man pages research.

Navigation

Directory Browser

1Browse 4.4BSD4.4BSD
1Browse Digital UNIXDigital UNIX 4.0e
1Browse FreeBSDFreeBSD 14.3
1Browse MINIXMINIX 3.4.0rc6-d5e4fc0
1Browse NetBSDNetBSD 10.1
1Browse OpenBSDOpenBSD 7.7
1Browse UNIX v7Version 7 UNIX
1Browse UNIX v10Version 10 UNIX

Manual Page Search

Manual Page Result

0 Command: hoc | Section: 1 | Source: UNIX v10 | File: hoc.1
HOC(1) General Commands Manual HOC(1) NAME hoc - interactive floating point language SYNOPSIS hoc [ file ... ] DESCRIPTION Hoc interprets a simple language for floating point arithmetic, at about the level of Basic, with C-like syntax and functions. The named files are read and interpreted in order. If no file is given or if file is hoc interprets the standard input. 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 the name by itself con- tains the value of the last expression evaluated. Certain variables are already initialized: E base of natural logs PI PHI golden ratio GAMMA Euler's constant DEG 180/PI, degrees per radian PREC maximum number of significant digits in output, initially 15; PREC=0 gives shortest `exact' values. Expressions are formed with these C-like operators, listed by decreas- ing precedence. ^ exponentiation ! - ++ -- * / % + - > >= < <= == != && || = += -= *= /= %= Built in functions include abs, acos, atan (one argument), cos, cosh, erf, erfc, exp, gamma, int, log, log10, sin, sinh, sqrt, tan, and tanh. The function read(x) reads a value into the variable x; the statement print prints a list of expressions that may include string constants such as "hello\n". 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; re- turn is used to return with a value from a function. Within a function or procedure, arguments are referred to as $1, $2, etc.; all other variables are global. EXAMPLES func gcd() { temp = abs($1) % abs($2) if(temp == 0) return abs($2) return gcd($2, temp) } for(i=1; i<12; i++) print gcd(i,12) SEE ALSO bc(1), dc(1) B. W. Kernighan and R. Pike, The Unix Programming Environment, Pren- tice-Hall, 1984 BUGS Error recovery is imperfect within function and procedure definitions. The treatment of newlines is not exactly user-friendly. HOC(1)

Navigation Options