summaryrefslogtreecommitdiff
path: root/static/unix-v10/man1/hoc.1
diff options
context:
space:
mode:
authorJacob McDonnell <jacob@jacobmcdonnell.com>2026-04-26 16:38:00 -0400
committerJacob McDonnell <jacob@jacobmcdonnell.com>2026-04-26 16:38:00 -0400
commit97d5c458cfa039d857301e1ca7d5af3beb37131d (patch)
treeb460cd850d0537eb71806ba30358840377b27688 /static/unix-v10/man1/hoc.1
parentb89dc2331a50c63f8b33272a5c4c61ab98abdaa3 (diff)
build: Better Build System
Diffstat (limited to 'static/unix-v10/man1/hoc.1')
-rw-r--r--static/unix-v10/man1/hoc.1156
1 files changed, 156 insertions, 0 deletions
diff --git a/static/unix-v10/man1/hoc.1 b/static/unix-v10/man1/hoc.1
new file mode 100644
index 00000000..18786cd9
--- /dev/null
+++ b/static/unix-v10/man1/hoc.1
@@ -0,0 +1,156 @@
+.TH HOC 1
+.CT 1 numbers
+.SH NAME
+hoc \(mi interactive floating point language
+.SH SYNOPSIS
+.B hoc
+[
+.I file ...
+]
+.SH DESCRIPTION
+.I Hoc
+interprets a simple language for floating point arithmetic,
+at about the level of Basic, with C-like syntax and
+functions.
+.PP
+The named
+.IR file s
+are read and interpreted in order.
+If no
+.I file
+is given or if
+.I file
+is
+.L -
+.I hoc
+interprets the standard input.
+.PP
+.I Hoc
+input consists of
+.I expressions
+and
+.IR statements .
+Expressions are evaluated and their results printed.
+Statements, typically assignments and function or procedure
+definitions, produce no output unless they explicitly call
+.IR print .
+.PP
+Variable names have the usual syntax, including
+.LR _ ;
+the name
+.L _
+by itself contains the value of the last expression evaluated.
+Certain variables are already initialized:
+.TP
+.B E
+base of natural logs
+.PD0
+.TP
+.B PI
+.TP
+.B PHI
+golden ratio
+.TP
+.B GAMMA
+Euler's constant
+.TP
+.B DEG
+180/PI, degrees per radian
+.TP
+.B PREC
+maximum number of significant digits in output, initially 15;
+.B PREC=0
+gives shortest `exact' values.
+.PD
+.PP
+Expressions are formed with these C-like operators, listed by
+decreasing precedence.
+.TP
+.B ^
+exponentiation
+.TP
+.B ! - ++ --
+.TP
+.B * / %
+.TP
+.B + -
+.TP
+.B > >= < <= == !=
+.TP
+.B &&
+.TP
+.B ||
+.TP
+.B = += -= *= /= %=
+.PP
+Built in functions include
+.BR abs ,
+.BR acos ,
+.B atan
+(one argument),
+.BR cos ,
+.BR cosh ,
+.BR erf ,
+.BR erfc ,
+.BR exp ,
+.BR gamma ,
+.BR int ,
+.BR log ,
+.BR log10 ,
+.BR sin ,
+.BR sinh ,
+.BR sqrt ,
+.BR tan ,
+and
+.BR tanh .
+The function
+.B read(x)
+reads a value into the variable
+.BR x ;
+the statement
+.B print
+prints a list of expressions that may include
+string constants such as
+.B \&\&\&"hello\en".
+.PP
+Control flow statements are
+.BR if - else ,
+.BR while ,
+and
+.BR for ,
+with braces for grouping.
+Newline ends a statement.
+Backslash-newline is equivalent to a space.
+.PP
+Functions and procedures are introduced by the words
+.B func
+and
+.BR proc ;
+.B return
+is used to return with a value from a function.
+Within a function or procedure,
+arguments are referred to as
+.BR $1 ,
+.BR $2 ,
+etc.; all other variables are global.
+.SH EXAMPLES
+.EX
+func gcd() {
+ temp = abs($1) % abs($2)
+ if(temp == 0) return abs($2)
+ return gcd($2, temp)
+}
+for(i=1; i<12; i++) print gcd(i,12)
+.EE
+.SH "SEE ALSO"
+.IR bc (1),
+.IR dc (1)
+.br
+B. W. Kernighan and R. Pike,
+.I
+The Unix Programming Environment,
+Prentice-Hall, 1984
+.SH BUGS
+Error recovery is imperfect within function and procedure definitions.
+.br
+The treatment of newlines is not exactly user-friendly.