Errors, exactly as the compiler says them
The error messages are part of the language. Each one below is what the compiler prints, and the site's tests fail if a message changes. Run a cell to see its output beside the expected one.
A string is not changed in place
Strings are immutable, as in Python; build a new one instead.
expected error: 'str' object does not support item assignment…
deriv cannot differentiate a call to a def
Write the expression inline in the fn instead of calling f.
expected error: cannot differentiate through…
A def does not change a record it is given
A record is a value: change a copy and return it. An array inside it can still be written in place.
expected error: `p` is a parameter, and a def does not change the values it is given…
Unknown function
expected error: unknown function…
Arity is checked
expected error: expects 2 argument…
Out of bounds says where
expected error: index 5 out of bounds for dimension 0 (size 2)…
An index before the start stops
A negative index counts from the end, as in Python: -1 is the last element. Two elements have no element -3.
expected error: index -3 out of bounds for dimension 0 (size 2)…
Shape mismatch
expected error: array shape mismatch: [2] vs [3]…
break outside a loop
expected error: `break`/`continue` outside a loop…
Undefined variable
expected error: undefined variable…
plot wants arrays
expected error: `plot` takes two arrays…
Keywords cannot name functions
record, test, show and the other keywords are reserved.
expected error: expected function name…
A number is not a condition
if and while take a Bool. Write the comparison you mean.
expected error: condition must be a boolean…
No arithmetic on a Bool
true is not 1. Every engine refuses this.
expected error: boolean…
An array is not a condition
A comparison of two arrays is a mask, not a Bool; the note says to write all(a == b).
expected error: condition must be a boolean, and this is an array…
% by zero stops the program
/ by zero gives inf, as IEEE floats do, but % and // by zero have no answer and stop.
expected error: division by zero in `a % b`…