Checking conditions: assert

### 12.2.4 Checking conditions: assert

The assert command breaks out of a function with an error.

- assert takes one argument:
  bool, a boolean.
- assert(bool) does nothing if bool is true, it returns from the function with an error if bool is false.

#### Example.

Define the function:
Input:

sqofpos(x):= {assert(x > 0); return x^2;}

then:

sqofpos(4)

Output:

16

Input:

sqofpos(-4)

Output:

assert failure: x>0 Error: Bad Argument Value

since -4 > 0 is false.