create a table - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Data Types : Tables, lists, and sets : table

table - create a table

Calling Sequence

table(F, L)

table(t)

Parameters

F

-

(optional) indexing function

L

-

(optional) list or set of initial table entries

t

-

(optional) table or array

Description

• 

A table is created either explicitly by a call to the table function or implicitly by assigning to an indexed name. Unlike arrays, where indices must be integers, the indices (or keys) of a table can be any value.

• 

The table function creates a table with initial values specified by L. If L is a list or set of equations then the left-hand side is taken to be the table index (key), and the right-hand side the entry (value). Otherwise, L is taken to be a list of entries with indices 1, 2, ... . The use of a set of initial values in the latter case is ambiguous because there is no ordering of set elements, and hence the ordering of the entries in the result may not correspond to the ordering in which the entries are given. If L is not specified, then an empty table is created.

  

Tables created with a list initializer, for example, table([a=A, b=B, c=C]), are created such that the assignment of the table entries proceeds from left to right.  That is, the first element of the list is inserted into the table first, the second is inserted second, and so on.

• 

New entries can be added to a table using the subscript notation. Thus, T := table([4]) is equivalent to:

  

T := table() and T[1] := 4,

  

or equivalently:

  

T[1] := 4 if T was unassigned (implicit creation).

  

Entries can be removed from a table by assigning a table entry to its own name using evaln.  Thus, T[1] := evaln(T[1]) removes the entry 4 from T.

• 

The indexing function F can be a procedure or a name specifying how indexing is to be performed; if null then ordinary indexing is implied. The built-in indexing functions are: symmetric, antisymmetric, sparse, diagonal, identity, and exception. For more information on indexing functions, see indexfcn.

• 

Tables have special evaluation rules (like procedures) so that if the name T has been assigned a table then T evaluates to T. The call op(T) yields the actual table structure; and op(op(T)) yields the components of the table, which are the indexing function (if there is one) and a list of equations for the tables values.

• 

The indices function can be used to obtain a sequence of a table's indices and likewise, the entries function returns a sequence of the table's entries.

• 

When the table constructor is called with a single argument, t, whose value is an existing table, a copy of t is returned. If t is an array, the resulting copy will be a table object. Since tables are mutable objects, and assignment in Maple is by-reference, making a copy of a table to work with is useful when you do not want to modify the original table.

Thread Safety

• 

The table command is thread-safe as of Maple 15.

• 

For more information on thread safety, see index/threadsafe.

Examples

table

table

(1)

table22,42

table1=22,2=42

(2)

S:=table2=45,4=61

S:=table2=45,4=61

(3)

S1,S2

S1,45

(4)

T:=tablesymmetric,c,b=x

T:=tablesymmetric,b,c=x

(5)

Tc,b

x

(6)

Tb,b

Tb,b

(7)

opT

tablesymmetric,b,c=x

(8)

opopT

symmetric,b,c=x

(9)

F:=tablesin=cos,cos=sin:

opopF

sin=cos,cos=sin

(10)

Fcosπ2

1

(11)

See Also

Array, copy, diagonal, entries, evaln, identity, indexed, indexfcn, indexfcn,antisymmetric, indexfcn,symmetric, indices, selection, sparse, type[table]


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam