other versions
- wheezy 1:6-5
HOC(1) | General Commands Manual | HOC(1) |
NAME¶
hoc - interactive floating point languageSYNOPSIS¶
hoc [ file ... ] [ -e expression ]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. 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 the name 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
- ! - ++ --
- * / %
- + -
- > >= < <= == !=
- &&
- ||
- = += -= *= /= %=
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)