Provided by: 9base_6-6_amd64

**NAME**

hoc - interactive floating point language

**SYNOPSIS**

hoc[file...] [-eexpression]

**DESCRIPTION**

Hocinterprets a simple language for floating point arithmetic, at about the level of BASIC, with C-like syntax and functions. The namedfilesare read and interpreted in order. If nofileis given or iffileishocinterprets the standard input. The-eoption allows input tohocto be specified on the command line, to be treated as if it appeared in a file.Hocinput consists ofexpressionsandstatements. Expressions are evaluated and their results printed. Statements, typically assignments and function or procedure definitions, produce no output unless they explicitly callE,PI,PHI,GAMMAandDEGare 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 areabs,acos,asin,atan(one argument),cos,cosh,exp,int,log,log10,sin,sinh,sqrt,tan, andtanh. The functionread(x)reads a value into the variablexand returns 0 at EOF; the statementif-else,while, andfor, with braces for grouping. Newline ends a statement. Backslash-newline is equivalent to a space. Functions and procedures are introduced by the wordsfuncandproc;returnis used to return with a value from a function.

**EXAMPLES**

func gcd(a, b) { temp = abs(a) % abs(b) if(temp == 0) return abs(b) return gcd(b, temp) } for(i=1; i<12; i++) print gcd(i,12)

**SOURCE**

/src/cmd/hoc

**SEE** **ALSO**

bc(1),dc(1) B. W. Kernighan and R. Pike,TheUnixProgrammingEnvironment,Prentice-Hall, 1984

**BUGS**

Error recovery is imperfect within function and procedure definitions. HOC(1plan9)