struct - Maple Help

MTM

 struct
 record constructor

 Calling Sequence struct(name1,value1,name2,value2,...);

Parameters

 namei - name or string valuei - any expression

Description

 • The struct command creates a Maple record.  A record is a fixed-size collection of items addressable by name.  Accessing individual field values is done via the :- or [] operators.  For example MyStruct:-field1 will give you value1 as does MyStruct[field1].
 • The :- operator binds more tightly than [], avoiding evaluation if the name field1 happens to have another meaning in the given scope.  Conversely, [] allows evaluation to happen, which allows for name resolution, and iteration over individual fields via the exports command.
 • The struct command is essentially a front end to the Record command. Aside from the different calling sequence, the struct command differs from the Record command in that it adds a ModulePrint definition so the record is displayed nicely.

Examples

 > $\mathrm{with}\left(\mathrm{MTM}\right):$
 > $s≔\mathrm{struct}\left('a',1,'b',2\right)$
 ${s}{≔}{\mathrm{a: 1 b: 2}}$ (1)
 > $s:-a$
 ${1}$ (2)