Introduction to Structures (Maxima 5.45.1 Manual)

Next: Functions and Variables for Structures, Previous: Structures, Up: Structures [Contents][Index]

#### 5.6.1 Introduction to Structures

Maxima provides a simple data aggregate called a structure. A structure is an expression in which arguments are identified by name (the field name) and the expression as a whole is identified by its operator (the structure name). A field value can be any expression.

A structure is defined by the `defstruct` function; the global variable `structures` is the list of user-defined structures. The function `new` creates instances of structures. The `@` operator refers to fields. `kill(S)` removes the structure definition S, and `kill(x@ a)` unbinds the field a of the structure instance x.

In the pretty-printing console display (with `display2d` equal to `true`), structure instances are displayed with the value of each field represented as an equation, with the field name on the left-hand side and the value on the right-hand side. (The equation is only a display construct; only the value is actually stored.) In 1-dimensional display (via `grind` or with `display2d` equal to `false`), structure instances are displayed without the field names.

There is no way to use a field name as a function name, although a field value can be a lambda expression. Nor can the values of fields be restricted to certain types; any field can be assigned any kind of expression. There is no way to make some fields accessible or inaccessible in different contexts; all fields are always visible.

Next: Functions and Variables for Structures, Previous: Structures, Up: Structures [Contents][Index]