Comments are like in C++ and Java (// to the end of the line, or between /* and */). Whitespace mostly doesn't matter. String literals are surrounded by single or double quotes and can contain similar escapes to C++.
Parentheses, square brackets, and braces must match but are otherwise completely interchangeable (except within strings).
The main data types are numbers and strings.
Assignment. If a complex expression is on the left, it is treated as the name of a variable. All variables are global.
Test for equality and inequality, respectively. Returns 1 for true and 0 for false. ≠ may also be written !=.
Addition, subtraction, multiplication, division, modulo, power
Choose a random number with a 95% probability of being in the specified range (normal distribution). ++ may be used instead.
Compare. <= and >= are also available for Unicodiphobes.
Convert a number to an integer, truncating.
Convert to and from a string.
Remove prefix or return 0 if it doesn't have the prefix.
Repeats the string the specified number of times.
Returns the first half of a string. Equivalent to string * .5.
Convert between Unicode values and strings. If a multi-character string is specified, chooses a random character. If an empty string is specified, returns an empty string.
Put some data in.
Get some data out (chosen randomly)
Remove some values
Remove all values
Makes all variables local (dynamically scoped) and suppresses side effects outside the imagine statement. (ask() will return a random number if imagined.)
Output the specified values. No spaces or newlines are output implicitly. An empty argument list clears the output.
Inputs a value as a string and returns it.
The most basic combination of statements. Chooses one randomly to execute. Any number of statements can be combined this way, and by default get equal probability; parentheses can change the probability.
Executes the statement a random number of times.
Half of a for loop. Executes the initializer, then executes the statement, too. The condition is not tested the first time through the loop.
Deciding when to do things
Execute the statement between each statement. Starts when this statement is encountered.
Execute the statement at some undetermined point in the future (unless the program exits first).
Sometimes the statement will execute, other times it won't. Equivalent to because(0±1>0).
Doesn't execute the statement. Equivalent to because(0).
Doesn't execute any similar statement. "Similar" meaning assigning the specified value to a specified variable or calling the specified function with the specified arguments (which are evaluated when the neverEver statement is encountered).
Executes the statement "later". Unlike normal lazy evaluation, evaluation of the statement doesn't happen automatically when you try to use the result. The specified variables are saved and restored when the program gets around to executing the statement; of course, such a lazy construct won't clean up those variables afterwards.
deadline(result of a procrastinate statement)
Executes a procrastinated statement. If no statement is specified, executes the next statement in the order they were procrastinated.
Makes the interpreter more eager to execute the statement. In fact, it may be so eager that it executes it more than once. Equivalent to because(1,1).
Gives the interpreter a reason to execute the statement. It is an error if the reason is invalid. Other effects depend on the surrounding statement, particularly the ; and then operators and the bodies of wild loops and superroutines.
Exits the program.
When entering the main program or a superroutine, the interpreter searches for any superroutines it contains. If it finds one that returns to the calling superroutine (initially main), it executes that instead of whatever it would have otherwise executed (choosing randomly if necessary).
Declares a superroutine, but otherwise acts as a never statement.
Returns to the specified superroutine. Acts as a never statement if the wrong superroutine name is specified.
Call the main program or enclosing superroutine, which may in turn call a different nested superroutine. It is an error for this statement to occur in the main program.
Type code in the top part and click Run; output will appear in the bottom part; input goes in the line at the very bottom. Warning: Do not double-click the Run button because it may crash your browser. Requires Java 1.5+.