HOC(1)HOC(1)

## NAME

hoc – interactive floating point language

## SYNOPSIS

`hoc``-e`*expression**file ...*

## DESCRIPTION

*Hoc*

The named
*files**file**file*`-`*hoc*`-e`*hoc*

*Hoc**expressions**statements*.*print*.

Variable names have the usual syntax, including
`_`;`_``E`,`PI`,`PHI`,`GAMMA``DEG`

Expressions are formed with these C-like operators, listed by decreasing precedence.

`^`

exponentiation

`! - ++ --`

`* / %`

`+ -`

`> >= < <= == !=`

`&&`

`||`

`= += -= *= /= %=`

Built in functions are
`abs`,`acos`,`asin`,`atan``cos`,`cosh`,`exp`,`int`,`log`,`log10`,`sin`,`sinh`,`sqrt`,`tan`,`tanh`.`read(x)``x``print`

Control flow statements are
`if`-`else`,`while`,`for`,

Functions and procedures are introduced by the words
`func``proc`;`return`

## 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

`/sys/src/cmd/hoc`

## SEE ALSO

*bc*(1),*dc*(1)

B. W. Kernighan and R. Pike,
*The Unix Programming Environment,
*Prentice-Hall, 1984

## BUGS

Error recovery is imperfect within function and procedure definitions.