table -- create a table
Introductiontable() creates a new empty table.
table(index1 = entry1, index2 = entry2...)
creates a new table with the given indices and entries.
Call(s)table()
table(index1 = entry1, index2 = entry2...)
Parametersindex1, index2... |
- | the indices: arbitrary MuPAD objects |
entry1, entry2... |
- | the corresponding entries: arbitrary MuPAD objects |
Returnsan object of type DOM_TABLE.
Related
Functions_assign, _index, array, assignElements, delete, DOM_ARRAY, DOM_LIST, DOM_TABLE, indexval
DetailsT, say, an
indexed call T[index] returns the corresponding entry. If
no such entry exists, the indexed expression T[index] is
returned symbolically.T[index] := entry
adds a new entry to an existing table T or overwrites an
existing entry associated with the index.table is used for the explicit creation of a table.
There also is the following mechanism for creating a table implicitly.
If the value of an identifier T, say, is neither a table nor an array
nor a list, then an indexed assignment
T[index] := entry is equivalent to T := table(index
= entry). I.e., implicitly, a new table with one entry is
created. Cf. example 2.
If the value of T was either a table or an array or a
list, then the indexed assignment only inserts a new entry without
changing the type of T implicitly.
delete.
Cf. example 3.table is a function of the system kernel.
Example
1The following call creates a table with two entries:
>> T := table(a = 13, c = 42)
table(
c = 42,
a = 13
)
The data may be accessed via indexed calls. Note the
symbolic result for the index b which does not have a
corresponding entry in the table:
>> T[a], T[b], T[c]
13, T[b], 42
Entries of a table may be changed via indexed assignments:
>> T[a] := T[a] + 10: T
table(
c = 42,
a = 23
)
Expression sequences may be
used as indices or entries, respectively. Note, however, that they have
to be enclosed in brackets when using them as input parameters for
table:
>> T := table((a, b) = "hello", a + b = (50, 70))
table(
a + b = (50, 70),
(a, b) = "hello"
)
>> T[a + b]
50, 70
Indexed access does not require additional brackets:
>> T[a, b] := T[a, b]." world": T
table(
a + b = (50, 70),
(a, b) = "hello world"
)
>> delete T:
Example
2Below, a new table is created implicitly by an idexed
assigment using an identifier T without a value:
>> delete T: T[4] := 7: T
table(
4 = 7
)
>> delete T:
Example
3Use delete to delete entries:
>> T := table(a = 1, b = 2, (a, b) = (1, 2))
table(
(a, b) = (1, 2),
b = 2,
a = 1
)
>> delete T[b], T[a, b]: T
table(
a = 1
)
>> delete T:
NIL to a table entry deleted this entry.
Now NIL is assigned to
that entry. Use delete
to delete entries.