HOC(1plan9)
π HOC(1plan9) π
okay bestie, sit DOWN, because this one is a whole little language and it's lowkey adorable. this is the hoc page from the Plan 9 manual, section 1 (that's "user commands" for the uninitiated, iykyk), and it's giving calculator-but-make-it-a-language energy. β¨
πΈ NAME πΈ
hoc β an interactive floating point language π
like. it does math. at you. interactively. iconic.
π SYNOPSIS π
hoc [ file ... ] [ -e expression ]
that's it. that's the whole summoning ritual. π«Ά
π¦ DESCRIPTION π¦
So hoc interprets a simple language for floating point arithmetic, at about the level of BASIC, but with C-like syntax and functions. no cap. it's baby's first programming language but she ATE and left no crumbs.
The named files are read and interpreted in order. If no file is given, hoc interprets the standard input. π
The -e option lets you hand input to hoc right there on the command line, and it gets treated as if it appeared in a file. so you can be lazy and efficient, which is the dream fr fr.
β¨ what even IS the input tho β¨
hoc input is made of expressions and **statements`.
- Expressions get evaluated, and their results get printed. periodt. π
- Statements β typically assignments and function or procedure definitions β produce no output unless they explicitly call
print. yeah, they're the quiet ones. main character silence. π€«
π variables π
Variable names have the usual syntax, and here's a cute lil detail: the name by itself (like, the lone variable name) contains the value of the last expression evaluated. she remembers. π
The variables E, PI, PHI, GAMMA and DEG are predefined. and DEG? that's 59.25..., which is degrees per radian. yes bestie, they came prepared. π
π operators, listed by DECREASING precedence π
so this is the vibe hierarchy. top of the list = highest precedence = loudest in the group chat.
^β exponentiation!,-,++,--*,/,%+,->,>=,<,<=,==,!=&&||=,+=,-=,*=,/=,%=
β οΈ heads up: precedence order is not a suggestion. it's the law. don't come crying to me when your math is mathing wrong because you ignored the list. π
π§ built-in functions π§
abs, acos, asin, atan (one argument), cos, cosh, exp, int, log, log10, sin, sinh, sqrt, tan, and tanh.
then there's read(x), which reads a value into the variable x and returns 0 at EOF. π
and the statement print prints a list of expressions that may include string constants such as "hello\n". yes you can say hi. slay.
β control flow β
the control flow statements are if-else, while, and for, with braces for grouping. classic. timeless. we love her.
- Newline ends a statement. π«
- Backslash-newline is equivalent to a space. (a little line-continuation moment, we've all been there)
π«Ά functions & procedures π«Ά
Functions and procedures are introduced by the words func and proc. return is used to return with a value from a function. that's the whole tea. β
π₯ EXAMPLES π₯
okay here's the moment you've all been waiting for β a recursive gcd, because of course:
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)
look at her go. recursion, abs, modulus, a for loop, print β the whole girlboss toolkit in like five lines. π β¨
π SOURCE π
/src/cmd/hoc
she lives there. that's her address. π
πΈ SEE ALSO πΈ
(the legends themselves wrote the book. literally. π)
π BUGS π
Error recovery is imperfect within function and procedure definitions.
so like... if you mess up inside afuncorproc, she might get a lil confused recovering. not her fault, just her truth. be gentle. π
okay that's the whole page bestie, every last detail, no crumbs left behind πβ¨ this was the HOC(1plan9) manual page, from the Plan 9 crew, and honestly? she ate. go do some floating point math and think of me. π¦π
π¦ where this page comes from
- debian bookworm: 9base 1:6-13 Β· Lucent
- debian trixie: 9base 1:6-14 Β· Lucent
- ubuntu jammy: 9base 1:6-11 Β· Lucent
- ubuntu noble: 9base 1:6-14 Β· Lucent
- ubuntu questing: 9base 1:6-15
- ubuntu resolute: 9base 1:6-15build1 Β· Lucent
- ubuntu stonking: 9base 1:6-15build1 Β· Lucent
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms