Mars features a small number of primitive functions and types, which cannot be written in the language itself (since they perform basic arithmetic or I/O operations). These constructs are always available.
Compare any two values of the same type for equality. This performs “deep” or “structural” equality, such that two values are only considered equal if all of their parts are equal, recursively. Returns 1 if x is equal to y, 0 otherwise. It is an error if the values are function objects (these cannot be compared for structural equality).
Returns x ÷ y, rounded towards negative infinity. It is an error if y is 0.
Returns x mod y, the modulus of floored division, such that div(x,y) * y + mod(x,y) equals x. The result has the same sign as y, the divisor (this is a “modulo” as opposed to “remainder”). For more information, see Wikipedia: Modulo operation. It is an error if y is 0.
Note
All of the array operations are pure, meaning they do not modify the given array object. Instead, they return a new array with the applicable updates. The impure module contains other operations which perform destructive modification to arrays.
Returns a new array of length length with all elements having the value default. It is an error if length is negative.
The element of array with index index. The first element has index 0. It is an error if array has no element at index.
Returns a new array which is array with element index replaced with value. It is an error if array has no element at index.
Returns a new array which is array with value appended onto the end.
Writes char as a byte to standard output. It is an error if char is outside the range [0, 255]. Returns 0.
Returns a string representation of value, which represents the value in Mars syntax if possible. Note that as strings are indistinguishable from arrays of integers, strings are displayed with array notation. Functions are not shown in Mars notation, but in an implementation-defined manner which may or may not include useful information about the function.