HOC(1) HOC(1)[top]NAMEhoc- interactive floating point languageSYNOPSIShoc[expression ] [ file ... ]-eDESCRIPTIONHoc 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 ishocinterprets the standard input. Theoption allows input to-ehocto 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 con‐ tains 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 decreas‐ ing 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 "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; return is used to return with a value from a function.-EXAMPLESfunc 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/hocSEE ALSObc(1), dc(1) B. W. Kernighan and R. Pike, The Unix Programming Environment, Pren‐ tice-Hall, 1984BUGSError recovery is imperfect within function and procedure definitions. HOC(1)

More information is available in_ _ _ | | | | | | | | | | | | __ | | __ __ | | __ __ | | __ \ \| |/ / \ \| |/ / \ \| |/ / \ \ / / \ \ / / \ \ / / \ / \ / \ / \_/ \_/ \_/

List of man pages available for

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]

Polar

Member of Polar

Based on Fawad Halim's script.

....................................................................

Vote for polarhome |