ABC QUICK REFERENCE

COMMANDS

WRITE expr
Write to screen; / before or after expr gives new line
READ address EG expr
Read expression from terminal to address; expr is example
READ address RAW
Read line of text
PUT expr IN address
Put value of expr in address
SET RANDOM expr
Start random sequence for random and choice
REMOVE expr FROM list
Remove one element from list
INSERT expr IN list
Insert in right place
DELETE address
Delete permanent location or table entry
PASS
Do nothing
KEYWORD expr KEYWORD ...
Execute user-defined command
KEYWORD
Execute refined command
CHECK
test Check test and stop if it fails
IF test:
   commands
If test succeeds, execute commands; no ELSE allowed
SELECT:
   test: commands
   ...
   test: commands
Select one alternative: try each test in order (one must succeed; the last test may be ELSE)
WHILE test:
    commands
As long as test succeeds execute commands
FOR name,... IN train:
   commands
Take each element of train in turn

HOW-TO's

HOW TO KEYWORD ...: commands
Define new command KEYWORD ...
HOW TO RETURN f: commands
Define new function f with no arguments (returns a value)
HOW TO RETURN f x: commands
Define new function f with one argument
HOW TO RETURN x f y: commands
Define new function f with two arguments
HOW TO REPORT pr: commands
Define new predicate pr with no arguments (succeeds/fails)
HOW TO REPORT pr x: commands
Define new predicate pr with one argument
HOW TO REPORT x pr y: commands
Define new predicate pr with two arguments
SHARE name,...
Share permanent locations (before commands of how-to)

Refinements (after the commands of a how-to)

KEYWORD: commands
Define command refinement
name: commands
Define expression- or test-refinement

Terminating commands

QUIT
Leave command how-to or command refinement, or leave ABC
RETURN expr
Leave function how-to or expression refinement, return value of expr
REPORT test
Leave predicate how-to or test-refinement, report outcome of test
SUCCEED
The same, report success
FAIL
The same, report failure

EXPRESSIONS AND ADDRESSES

666, 3.14, 3.14e-9
Exact constants
expr,expr,...
Compound
name,name,...
Naming (may also be used as address)
text@p
"ABCD"@2 = "BCD" (also address)
text|q
"ABCD"|3 = "ABC" (also address)
text@p|q
"ABCD"@2|1 = "BCD"|1 = "B"
table[expr]
Table selection (also address)
"Jan", 'Feb', 'Won''t!'
Textual displays (empty: "" or '')
"value = `expr`;"
Conversion of expr to text
{1; 2; 2; ...}
List display (empty: {})
{1..9; ...}, {"a".."z"; ...}
List of consecutive values
{["Jan"]: 1; ["Feb"]: 2; ...}
Table display (empty: {})
f, f x, x f y
Result of function f (no permanent effects)
name
Result of refinement (no permanent effects)

TESTS

x < y, x <= y, x >= y, x > y, x = y, x <> y, 0 <= d < 10
Order tests (<> means 'not equals')
pr, pr x, x pr y
Outcome of predicate pr (no permanent effects)
name
Outcome of refinement (no permanent effects)
test AND test AND ...
Fails as soon as one of the tests fails
test OR test OR ...
Succeeds as soon as one of the tests succeeds
NOT test
SOME name,... IN train HAS test
Sets name, ... on success
EACH name,... IN train HAS test
Sets name, ... on failure
NO name,... IN train HAS test
Sets name, ... on failure

PREDEFINED FUNCTIONS AND PREDICATES

Functions and predicates on numbers

~x
Approximate value of x
exactly x
Exact value of x
exact x
Test if x is exact
+x, x+y, x-y, -x, x*y, x/y
Plain arithmetic
x**y
x raised to the power y
root x, n root x
Square root, n-th root
abs x, sign x
Absolute value, sign (= -1, 0, or +1)
round x, floor x, ceiling x
Rounded to whole number
n round x
x rounded to n digits after decimal point
a mod n
Remainder of a on division by n
*/x
Numerator of exact number x
/*x
Denominator
random
Random approximate number r, 0 <= r < 1
e, exp x
Base of natural logarithm, exponential function
log x, b log x
Natural logarithm, logarithm to the base b
pi, sin x, cos x, tan x, arctan x
Trigonometric functions, with x in radians
angle (x, y), radius (x, y)
Angle of and radius to point (x, y)
c sin x, c cos x, c tan x
Similar, with the circle divided into c parts
c arctan x, c angle (x, y)
(e.g. 360 for degrees)
now
e.g. (1999, 12, 31, 23, 59, 59.999)

Functions on texts

t^u
t and u joined into one text
t^^n
t repeated n times
lower t
lower "aBc" = "abc"
upper t
upper "aBc" = "ABC"
stripped t
Strip leading and trailing spaces from t
split t
Split text t into words

Function on tables

keys table
List of all keys in table

Functions and predicates on trains

#train
Number of elements in train
e#train
Number of elements equal to e
e in train, e not.in train
Test for presence or absence
min train
Smallest element of train
e min train
Smallest element larger than e
max train, e max train
Largest element
train item n
n-th element
choice train
Random element

Functions on all types

x<<n
x converted to text, aligned left in width n
x><n
The same, centred
x>>n
The same, aligned right

THE CHARACTERS

This is the order of all characters that may occur in a text. (The first is a space.)
 !"#$%&'()*+,-./		
0123456789:;<=>?
@ABCDEFGHIJKLMNO		
PQRSTUVWXYZ[\]^_
`abcdefghijklmno
pqrstuvwxyz{|}~