# Statements and Expressions

- [Introduction](introduction.md)

- [Starting, Interrupting and Terminating](startup-interrupt-quit.md)

  - [`<Ctrl>-C`](startup-interrupt-quit.md#literal-literal-control-c-key-ctrl-c)

  - [`quit;`](startup-interrupt-quit.md#literal-literal-quit-quit)

  - [`<Ctrl>-D`](startup-interrupt-quit.md#literal-literal-control-d-key-ctrl-d)

  - [`<Ctrl>-\`](startup-interrupt-quit.md#literal-literal-control-key-ctrl)

- [Identifiers](identifier.md)

- [Assignment](assignment.md)

  - [Simple Assignment](assignment.md#simple-assignment)

    - [`x := expression;`](assignment.md#literal-literal-x-expression)

    - [`Example: Identifiers`](assignment.md#example-ex-b15b93)

    - [`x₁, x₂, ..., xₙ := expression;`](assignment.md#literal-literal-x1-x2-xn-expression)

    - [`_ := expression;`](assignment.md#literal-literal-expression)

    - [`assigned x: Var → BoolElt`](assignment.md#operation-operation-assigned-var-boolelt)

    - [`Example: Multiple Returns`](assignment.md#example-ex-24e461)

  - [Indexed Assignment](assignment.md#indexed-assignment)

    - [`x[expr₁][expr₂]...[exprₙ] := expression;`](assignment.md#literal-literal-x-expr1-expr2-exprn-expression)

    - [`x[expr₁,expr₂,...,exprₙ] := expression;`](assignment.md#literal-literal-x-expr1-expr2-exprn-expression-2)

    - [`Example: Indexing`](assignment.md#example-ex-36ee87)

  - [Generator Assignment](assignment.md#generator-assignment)

    - [`E<x₁, x₂, ...xₙ> := expression;`](assignment.md#literal-literal-e-x1-x2-xn-expression)

    - [`E<[x]> := expression;`](assignment.md#literal-literal-e-x-expression)

    - [`Example: Generator Naming Sequence`](assignment.md#example-ex-b26be4)

    - [`AssignNames(~S, [s₁, ... sₙ] ): Str, [ MonStgElt ]`](assignment.md#function-assignnames-str-monstgelt-ref)

    - [`Example: Generator Naming`](assignment.md#example-ex-92cebe)

  - [Mutation Assignment](assignment.md#mutation-assignment)

    - [`x o:= expression;`](assignment.md#literal-literal-operator-x-o-expression)

    - [`Example: Mutation Assignment`](assignment.md#example-ex-f76a1d)

  - [Deletion of Values](assignment.md#deletion-of-values)

    - [`delete x: Var`](assignment.md#operation-operation-delete-var)

- [Boolean Values](boolean.md)

  - [Creation of Booleans](boolean.md#creation-of-booleans)

    - [`Booleans() → Bool`](boolean.md#function-booleans)

    - [`# B: Bool → RngIntElt`](boolean.md#operation-operation-bool-rngintelt)

    - [`true`](boolean.md#literal-literal-true-true)

    - [`false`](boolean.md#literal-literal-false-false)

    - [`Random(B): Bool → BoolElt`](boolean.md#function-random-bool)

  - [Boolean Operators](boolean.md#boolean-operators)

    - [`x and y: BoolElt, BoolElt → BoolElt`](boolean.md#operation-operation-and-boolelt-boolelt-boolelt)

    - [`x or y: BoolElt, BoolElt → BoolElt`](boolean.md#operation-operation-or-boolelt-boolelt-boolelt)

    - [`x xor y: BoolElt, BoolElt → BoolElt`](boolean.md#operation-operation-xor-boolelt-boolelt-boolelt)

    - [`not x: BoolElt → BoolElt`](boolean.md#operation-operation-not-boolelt-boolelt)

  - [Equality Operators](boolean.md#equality-operators)

    - [`x eq y: Any, Any → BoolElt`](boolean.md#operation-op-eq-any-any)

    - [`x ne y: Any, Any → BoolElt`](boolean.md#operation-op-ne-any-any)

    - [`x cmpeq y: Any, Any → BoolElt`](boolean.md#operation-operation-cmpeq-any-any-boolelt)

    - [`x cmpne y: Any, Any → BoolElt`](boolean.md#operation-operation-cmpne-any-any-boolelt)

    - [`Example: Equality`](boolean.md#example-ex-838d04)

  - [Iteration](boolean.md#iteration)

    - [`Example: Booleans`](boolean.md#example-ex-e85cda)

- [Coercion](coercion.md)

  - [`S ! x: Str, Elt → Elt`](coercion.md#operation-op-str-elt)

  - [`IsCoercible(S, x): Str, Elt → Bool, Elt`](coercion.md#function-iscoercible-str-elt)

- [The where $\ldots$ is Construction](where-is.md)

  - [`expression₁ where identifier is expression₂`](where-is.md#literal-literal-where-is-expression1-where-identifier-is-expression2)

  - [`expression₁ where identifier := expression₂`](where-is.md#literal-literal-where-expression1-where-identifier-expression2)

  - [`Example: where`](where-is.md#example-ex-f8d9ed)

- [Conditional Statements and Expressions](conditional.md)

  - [The Simple Conditional Statement](conditional.md#the-simple-conditional-statement)

    - [`if`](conditional.md#literal-literal-if-if-boolean-expression-then-br-indent-statements1-br-else-br-indent-statements2-br-end-if)

    - [`if`](conditional.md#literal-literal-if-if-boolean-expression-then-br-indent-statements-br-end-if)

    - [`elif`](conditional.md#literal-literal-elif-if-boolean-expression1-then-br-indent-statements1-br-elif-boolean-expression2-then-br-indent-statements2-br-else-br-indent-statements3-br-end-if)

    - [`Example: if`](conditional.md#example-ex-6d1681)

  - [The Simple Conditional Expression](conditional.md#the-simple-conditional-expression)

    - [`Boolean expression select expr₁ else expr₂`](conditional.md#literal-literal-select-boolean-expression-select-expr1-else-expr2)

    - [`Example: In Line Conditional`](conditional.md#example-ex-bbc380)

  - [The Case Statement](conditional.md#the-case-statement)

    - [`case expr : when exprᵢ : statements end case`](conditional.md#literal-literal-case-case-expr-when-expri-statements-end-case)

    - [`Example: case`](conditional.md#example-ex-62b01f)

  - [The Case Expression](conditional.md#the-case-expression)

    - [`case< expr | expr_left,1 : expr_right,1, ..., expr_left,n : expr_right,n, default : expr_def>`](conditional.md#literal-literal-case-case-expr-expr-left-1-expr-right-1-expr-left-n-expr-right-n-default-expr-def)

- [Error Handling Statements](error-handling.md)

  - [The Error Objects](error-handling.md#the-error-objects)

    - [`Error(x): Any → Err`](error-handling.md#function-error-any)

    - [`e`Position: Err → MonStgElt`](error-handling.md#attribute-attribute-e-position-err-monstgelt)

    - [`e`Traceback: Err → MonStgElt`](error-handling.md#attribute-attribute-e-traceback-err-monstgelt)

    - [`e`Object: Err → Any`](error-handling.md#attribute-attribute-e-object-err-any)

    - [`e`Type: Err → MonStgElt`](error-handling.md#attribute-attribute-e-type-err-monstgelt)

  - [Error Checking and Assertions](error-handling.md#error-checking-and-assertions)

    - [`error expression, ..., expression;`](error-handling.md#literal-literal-error-error-expression-expression)

    - [`error if Boolean expression, expression, ..., expression;`](error-handling.md#literal-literal-error-if-error-if-boolean-expression-expression-expression)

    - [`assert Boolean expression;`](error-handling.md#literal-literal-assert-assert-boolean-expression)

    - [`assert2 Boolean expression;`](error-handling.md#literal-literal-assert2-assert2-boolean-expression)

    - [`assert3 Boolean expression;`](error-handling.md#literal-literal-assert3-assert3-boolean-expression)

  - [Catching Errors](error-handling.md#catching-errors)

    - [`try statements catch e statements end try`](error-handling.md#literal-literal-try-try-statements-catch-e-statements-end-try)

    - [`Example: while`](error-handling.md#example-ex-33665a)

- [Iterative Statements](iteration.md)

  - [Definite Iteration](iteration.md#definite-iteration)

    - [`for i := expr₁ to expr₂ by expr₃ do`](iteration.md#literal-literal-for-for-i-expr1-to-expr2-by-expr3-do)

    - [`for i := expr₁ to expr₂ do`](iteration.md#literal-literal-for-for-i-expr1-to-expr2-do)

    - [`for`](iteration.md#literal-literal-for-for-x-in-s-do-br-indent-statements-br-end-for)

  - [Indefinite Iteration](iteration.md#indefinite-iteration)

    - [`while`](iteration.md#literal-literal-while-while-boolean-expression-do-br-indent-statements-br-end-while)

    - [`Example: while`](iteration.md#example-ex-9a6f96)

    - [`repeat`](iteration.md#literal-literal-repeat-repeat-br-indent-statements-br-until-boolean-expression)

    - [`Example: repeat`](iteration.md#example-ex-bdac72)

    - [`for random`](iteration.md#literal-literal-for-random-for-random-x-in-s-do-br-indent-statements-br-end-for)

  - [Dual Iteration](iteration.md#dual-iteration)

    - [`for`](iteration.md#literal-literal-for-for-i-x-in-s-do-br-indent-statements-br-end-for)

    - [`for random`](iteration.md#literal-literal-for-random-for-random-i-x-in-s-do-br-indent-statements-br-end-for)

  - [Early Exit from Iterative Statements](iteration.md#early-exit-from-iterative-statements)

    - [`continue;`](iteration.md#literal-literal-continue-continue)

    - [`continue identifier;`](iteration.md#literal-literal-continue-continue-identifier)

    - [`break;`](iteration.md#literal-literal-break-break)

    - [`break identifier;`](iteration.md#literal-literal-break-break-identifier)

    - [`Example: break`](iteration.md#example-ex-c95fc5)

- [Runtime Evaluation: the eval Expression](eval-expression.md)

  - [`eval expression`](eval-expression.md#literal-literal-eval-eval-expression)

  - [`Example: eval1`](eval-expression.md#example-ex-9398c3)

  - [`Example: eval2`](eval-expression.md#example-ex-c351ee)

- [Comments and Continuation](comment-continuation.md)

  - [`//`](comment-continuation.md#literal-literal)

  - [`/*  */`](comment-continuation.md#literal-literal-2)

  - [`\`](comment-continuation.md#literal-literal-3)

  - [`Example: Various`](comment-continuation.md#example-ex-bc5419)

- [Timing](timing.md)

  - [`Cputime() → FldReElt`](timing.md#function-cputime)

  - [`Cputime(t): FldReElt → FldReElt`](timing.md#function-cputime-fldreelt)

  - [`Realtime() → FldReElt`](timing.md#function-realtime)

  - [`Realtime(t): FldReElt → FldReElt`](timing.md#function-realtime-fldreelt)

  - [`ClockCycles() → RngIntElt`](timing.md#function-clockcycles)

  - [`Time() → MonStgElt`](timing.md#function-time)

  - [`Time(T): MonStgElt → MonStgElt`](timing.md#function-time-monstgelt)

  - [`time statement;`](timing.md#literal-literal-time-time-statement)

  - [`vtime flag: statement;`](timing.md#literal-literal-vtime-vtime-flag-statement)

  - [`vtime flag, n: statement:`](timing.md#literal-literal-vtime-vtime-flag-n-statement)

  - [`SetShowRealTime(v): BoolElt`](timing.md#function-setshowrealtime-boolelt)

  - [`GetShowRealTime() → BoolElt`](timing.md#function-getshowrealtime)

  - [`Example: Time`](timing.md#example-ex-4cec25)

  - [`Example: Time Multi Threaded`](timing.md#example-ex-de9abd)

- [Types, Category Names, and Structures](type.md)

  - [`Type(x): Elt → Cat`](type.md#function-type-elt)

  - [`Category(x): Elt → Cat`](type.md#function-category-elt)

  - [`ExtendedType(x): Elt → ECat`](type.md#function-extendedtype-elt)

  - [`ExtendedCategory(x): Elt → ECat`](type.md#function-extendedcategory-elt)

  - [`ISA(T, U): Cat, Cat → BoolElt`](type.md#function-isa-cat-cat)

  - [`ISA(T, U): Cat, ECat → BoolElt`](type.md#function-isa-cat-ecat)

  - [`ISA(T, U): ECat, Cat → BoolElt`](type.md#function-isa-ecat-cat)

  - [`ISA(T, U): ECat, ECat → BoolElt`](type.md#function-isa-ecat-ecat)

  - [`BaseType(T): ECat → Cat`](type.md#function-basetype-ecat)

  - [`# T: ECat → RngIntElt`](type.md#operation-operation-ecat-rngintelt)

  - [`T[i]: ECat, RngIntElt → .`](type.md#literal-literal-t-i-ecat-rngintelt)

  - [`Example: Extended Type Accessors`](type.md#example-ex-1892d6)

  - [`MakeType(S): MonStgElt → Cat`](type.md#function-maketype-monstgelt)

  - [`ElementType(S): Str → Cat`](type.md#function-elementtype-str)

  - [`CoveringStructure(S, T): Str, Str → Str`](type.md#function-coveringstructure-str-str)

  - [`ExistsCoveringStructure(S, T): Str, Str → BoolElt, Str`](type.md#function-existscoveringstructure-str-str)

  - [`Example: Type Structures`](type.md#example-ex-55c1aa)

- [Random Object Generation](random.md)

  - [`SetSeed(s, c): RngIntElt, RngIntElt`](random.md#function-setseed-rngintelt-rngintelt)

  - [`SetSeed(s): RngIntElt`](random.md#function-setseed-rngintelt)

  - [`GetSeed() → RngIntElt, RngIntElt`](random.md#function-getseed)

  - [`Random(S): Str → Elt`](random.md#function-random-str)

  - [`Random(a, b): RngIntElt, RngIntElt → RngIntElt`](random.md#function-random-rngintelt-rngintelt)

  - [`Random(b): RngIntElt → RngIntElt`](random.md#function-random-rngintelt)

  - [`Example: Is Intrinsic`](random.md#example-ex-a0e14a)

- [Miscellaneous](misc.md)

  - [`IsIntrinsic(S): MonStgElt → Bool, Intrinsic`](misc.md#function-isintrinsic-monstgelt)

  - [`Example: Is Intrinsic`](misc.md#example-ex-c50516)
