From 78e51a8c6678b6e3dff3d619aa786669f531f4bc Mon Sep 17 00:00:00 2001 From: rsc Date: Fri, 14 Jan 2005 03:45:44 +0000 Subject: checkpoint --- man/man1/hoc.html | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 man/man1/hoc.html (limited to 'man/man1/hoc.html') diff --git a/man/man1/hoc.html b/man/man1/hoc.html new file mode 100644 index 00000000..21107e8e --- /dev/null +++ b/man/man1/hoc.html @@ -0,0 +1,136 @@ + +hoc(1) - Plan 9 from User Space + + + + +
+
+
HOC(1)HOC(1) +
+
+

NAME
+ +
+ + hoc – interactive floating point language
+ +
+

SYNOPSIS
+ +
+ + 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
+ ! − ++ −−
+ * / %
+ + −
+ > >= < <= == !=
+ &&
+ ||
+ = += −= *= /= %=
+ +
+
+ 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.
+ +
+

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
+ +
+ + /usr/local/plan9/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.
+ +
+ +

+
+
+ + +
+
+
+Space Glenda +
+
+ + -- cgit v1.2.3