Variables appear here once the program runs. Use Step to watch them change line by line.
Tick “Record trace table” below the editor, then Run. Each row shows the variable values after a line executes, the way you would fill in a trace table by hand. Recording stops after 400 rows.
Storing values and output
5→x © store 5 in x x:=x+1 Disp x Disp i,i^2 © displays 3 9 Request "Enter n",n © values come from the box above the output
Type -> to get →. Comments start with ©. Several statements can share a line if separated by a colon. Names are not case sensitive: Count and count are the same variable.
Programs and functions
Define area(r)=
Prgm
Local a
π r^2→a
Disp "Area:",a
EndPrgm
Define f(x)=x^3-2x-5
Define fact(n)=
Func
Local p,i
1→p
For i,1,n
p*i→p
EndFor
Return p
EndFunc
A Prgm displays things and can change variables outside it; a Func gives back a value with Return. Lines outside any definition run first, top to bottom. If there are none, the first definition that needs no inputs is run for you. Run a definition yourself by calling it, e.g. area(3).
Decisions
If a≤b Then
Disp a
ElseIf a=b Then
Disp "equal"
Else
Disp b
EndIf
If x<0
Disp "negative" © one-line If: no Then, no EndIf
Comparisons: = ≠ < > ≤ ≥. Combine with and, or, not.
Repetition
For i,1,n © 1 to n inclusive
Disp i^2
EndFor
For x,0,1,0.1 © optional step
While x^2<1000
x+1→x
EndWhile
Loop
randInt(1,6)→d
If d=6 Then
Exit
EndIf
EndLoop
Exit leaves the current loop, Cycle skips to its next pass and Stop ends the whole program.
Arithmetic
+ − * /, ^ for powers (² and ³ also work), n! for factorials and & to join strings. Writing 2x, 3(a+b) or 2πr multiplies, as in maths. Arithmetic on a list applies to every item.
Built-in functions
| rand(), rand(n) | random real number in [0, 1), or a list of n of them |
| randInt(a,b), randInt(a,b,n) | random integer from a to b inclusive, or a list of n of them |
| randNorm(μ,σ), randBin(n,p) | random normal and binomial values |
| sqrt or √, abs, int, floor, ceiling | root, absolute value, rounding down and up |
| round(x,d) | round to d decimal places (d optional) |
| mod(a,b), remain(a,b), intDiv(a,b), gcd, lcm | remainders and whole-number division |
| sin, cos, tan, asin, acos, atan | radians |
| e^(x), exp, ln, log(x), log(x,b) | log(x) is base 10, ln is base e |
| π, e | constants |
| {2,5,1}, L[1], dim(L) | a list, its first item, its length |
| seq(i^2,i,1,10) | the list {1,4,9,…,100} |
| sum, product, mean, median, min, max | work on a list or on several numbers |
| augment(L1,L2), newList(n), sortA(L), sortD(L) | join lists, a list of n zeros, sorted copies |
| SortA L | sorts the list stored in a variable, in place |
| left(L,n), right(L,n), mid(L,s,n), cumulativeSum(L) | parts and running totals of a list |
| nCr(n,r), nPr(n,r) | combinations and permutations |
| string(x), expr(s) | number to text and back |
| when(cond,a,b) | a if the condition holds, otherwise b |
Editor shortcuts
Tab indents, Shift+Tab outdents, Enter keeps the indent and closes a block for you, Ctrl+Enter runs. Variables you have stored a value in, and programs and functions you have defined, are shown in purple once the editor recognises them. As you type a name, a list of matching variables, functions, keywords and built-ins appears: Tab inserts the highlighted one, ↑ and ↓ move the highlight (after which Enter also inserts), Esc dismisses, and Tab or Ctrl+Space opens the list on demand. Untick “Suggest names as you type” below the editor to turn the list off. Your code is kept in this browser between visits.