Docs.
Everything APL — one board, all the chalk you need.
Variables
define a new variable with v
Use v to declare a variable. You must give it a type, a name, and a value.
v type name = value
v int age = 20 ~ whole number v double price = 9.99 ~ decimal number v bool done = false ~ true or false v string name = Ahmed ~ text
| Type | What it stores |
|---|---|
| int | Whole numbers — 0, 5, -3, 100 |
| double | Decimal numbers — 3.14, 0.5, -1.8 |
| bool | true or false only |
| string | Any text — name, word, sentence |
write to the screen with print
print shows a value, a variable, a quoted string, or the result of a math expression.
print value_or_expression
print 42 ~ prints: 42 print age ~ prints the value of age print "Hello World" ~ prints: Hello World print 5 + 3 ~ prints: 8 print age + 1 ~ prints age + 1
42
20
Hello World
8
21
Reassign
change a variable's value with n v
Once a variable is declared, use n v to give it a new value. You can use its current value in the expression on the right.
n v name = expression
v int x = 10 n v x = x + 5 ~ x is now 15 n v x = x * 2 ~ x is now 30 n v x = 0 ~ x is now 0 print x 0
User Input
read from the keyboard with r
r pauses the program and waits for the user to type something. The variable must be declared first — APL uses its type to convert the input correctly.
r name
v int age = 0 ~ declare first r age ~ prompt appears: user types 25 print age 25
If / Else
run code only when a condition is true
Wrap code in { } — APL runs it only if the condition is true.
Add else { } to handle the false case.
if name condition value { ~ runs when true } else { ~ runs when false }
v int score = 85 if score > 60 { print "Pass" } else { print "Fail" }
Pass
Supported comparison operators inside if:
Loop
repeat code while a condition is true with Loop
Loop keeps running the block inside { } as long as the condition holds.
Don't forget to change the variable inside — otherwise it loops forever!
Loop name condition value { ~ repeats while true }
v int x = 1 Loop x < 6 { print x n v x = x + 1 }
1
2
3
4
5
Functions
define once, call anywhere with func and call
A func bundles lines of code under a name so you can reuse them. Use call to run it whenever you need it.
func name { ~ your code here } call name
func greet { print "Hello from APL!" print "Welcome." } call greet call greet ~ call it as many times as you want
Hello from APL!
Welcome.
Hello from APL!
Welcome.
Operators
math and comparison symbols APL understands
| Symbol | Operation |
|---|---|
| + | addition |
| - | subtraction |
| * | multiplication |
| / | integer division (no decimals) |
| Symbol | Meaning |
|---|---|
| > | greater than |
| < | less than |
| A= | equal to |
| != | not equal to |
| >= | greater than or equal |
| <= | less than or equal |
Types
the four data types APL supports
| Type | Example value | What it means |
|---|---|---|
| int | 5, -3, 100 | Whole integer number |
| double | 3.14, 0.5 | Number with decimal point |
| bool | true, false | Boolean — yes or no |
| string | Ahmed, Hello | Plain text (no quotes needed) |
Cheat Sheet
the whole language on one board
~ ─── Variables ─────────────────── v int x = 5 v double pi = 3.14 v bool done = false v string name = Ahmed ~ ─── Print ─────────────────────── print x print "Hello World" print 5 + x ~ ─── Reassign ──────────────────── n v x = x + 1 ~ ─── Input ─────────────────────── r x ~ ─── If / Else ─────────────────── if x > 10 { print "big" } else { print "small" } ~ ─── Loop ──────────────────────── Loop x < 10 { print x n v x = x + 1 } ~ ─── Functions ─────────────────── func greet { print "Hello!" } call greet