Write RUNE

chaos: 1

Enter to run

Output

integers, one per line

Trace playback

Debugger idle.

Runtime internals
Chaos threshold: 1
Variables: (none)

How RUNE works

version 0.9

01

Truth has a lifetime

@chaos n persists a threshold. chaos n applies one temporarily, then restores the surrounding value.

@chaos 1
chaos 500
  if (1)
    99
  else
    0
  end if
end chaos
1  → threshold is 1 again
02

Text is arithmetic

Strings collapse to the sum of their Unicode code points. That makes emoji and ordinary text valid numeric operands.

rocket = "🚀"
face = "😀"
rocket - face  → 128
03

State sticks around

Variables and the chaos threshold persist in this expiring browser session. Failed runs never commit partial changes.

answer = 40
answer = answer + 2
answer  → 42

Control flow

Conditional
if (x) · elif (x) · else · end if
While loop
while (x) · end while
Counted loop
for i from 1 to 5 step 2 · end for
Temporary chaos
chaos expression · end chaos
Function
function add(a, b) · return a + b · end function

Operators

Highest precedence first.

  • calls · literals · names · strings · grouping
  • **
  • prefix - ~
  • * / %
  • + -
  • << >>
  • &
  • ^
  • |
  • < > <= >= == !=
  • not
  • and
  • or

Values & names

Integers
42 · 0b101010 · 0o52 · 0x2A
Strings
Double quoted; converted to Unicode code-point sums.
Names
Start with a letter or _; keywords are reserved.
Logic
and, or, and not short-circuit and return 1 or 0.
Comments
# ignores the rest of the line.

Blocks use typed endings such as end if, end for, end chaos, and end function. Bare end is invalid.