Har(d)
Jump to navigation
Jump to search
Har(d) is an esolang created by User:LEOMOK. It is inspired by the constructed language Kay(f)bop(t). It uses an infinite stack of arbitrary-precision rational numbers, as well as a global array.
Syntax
Each instruction takes an argument in Har(d). A program is written like this:
instruction(arg)instruction(arg)...
Arguments are rational numbers, with bignum numerators and denominators, like 123
, 0.456
and 78/9
.
Instructions
In each instruction, A is the argument, and [n] is the 0-indexed nth stack item. Basic
. - Push A to the stack.
+ - top = top + [A], then remove [A]
- - top = top - [A], then remove [A]
* - top = top * [A], then remove [A]
/ - top = top / [A], then remove [A]
\ - top = int(top / [A]), then remove [A]. /(1)
is an idiom for truncating the top stack item.
% - top = top % [A], then remove [A]
& - top = int(top) AND int([A]) (bitwise), then remove [A]
| - top = int(top) OR int([A]) (bitwise), then remove [A]
~ - top = NOT int([A]) (bitwise), then remove [A]
^ - top = int(top) XOR int([A]) (bitwise), then remove [A]
$ - Pop [A]
: - Duplicate [A]
; - Swap [A] and top
[ - Print [A] as nunmber
] - Print [A] as Unicode character
{ - Input number into [A]
} - Input Unicode character into [A]
p - array([A]) = top
g - Push array([A]) to stack.
Control flow
@ - Goto A # - Label A < - If top < 0 goto A > - If top > 0 goto A = - If top = 0 goto A ' - Goblins. Jump to last @ and excute next instruction. " - Terminate program instruction with exit code [A].
Comments are indicated in parentheses.