EnglishFrenchSpanish

OnWorks favicon

hocplan9 - Online in the Cloud

Run hocplan9 in OnWorks free hosting provider over Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator

This is the command hocplan9 that can be run in the OnWorks free hosting provider using one of our multiple free online workstations such as Ubuntu Online, Fedora Online, Windows online emulator or MAC OS online emulator

PROGRAM:

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


/src/cmd/hoc

Use hocplan9 online using onworks.net services


Free Servers & Workstations

Download Windows & Linux apps

  • 1
    oStorybook
    oStorybook
    oStorybook l'outil privil�gi� des
    �crivains. ATTENTION : voir sur
    http://ostorybook.tuxfamily.org/v5/
    --en_EN oStorybook the right tool for
    writers. WARNIN...
    Download oStorybook
  • 2
    Asuswrt-Merlin
    Asuswrt-Merlin
    Asuswrt-Merlin is a third party
    firmware for select Asus wireless
    routers. Based on the Asuswrt firmware
    developed by Asus, it brings tweaks, new
    features and ...
    Download Asuswrt-Merlin
  • 3
    Atom
    Atom
    Atom is a text editor that's
    modern, approachable and full-featured.
    It's also easily customizable- you
    can customize it to do anything and be
    able to ...
    Download Atom
  • 4
    Osu!
    Osu!
    Osu! is a simple rhythm game with a well
    thought out learning curve for players
    of all skill levels. One of the great
    aspects of Osu! is that it is
    community-dr...
    Download Osu!
  • 5
    LIBPNG: PNG reference library
    LIBPNG: PNG reference library
    Reference library for supporting the
    Portable Network Graphics (PNG) format.
    Audience: Developers. Programming
    Language: C. This is an application that
    can also...
    Download LIBPNG: PNG reference library
  • 6
    Metal detector based on  RP2040
    Metal detector based on RP2040
    Based on Raspberry Pi Pico board, this
    metal detector is included in pulse
    induction metal detectors category, with
    well known advantages and disadvantages.
    RP...
    Download Metal detector based on RP2040
  • More »

Linux commands

Ad