AS initial-value
= initial-value BASE integer |
DISPLAY ON | OFF
ADJUSTABLE TRUE | FALSE VERBOSE TRUE | FALSE |
Examples (see ASSIGN and other table functions for explanations of the use of tables):
- Defines the structure of a table and (optionally) initializes it
- It is not necessary to define a table before using it, but table operations may execute faster if the table is defined.
- Do not use DEFINE to assign values to individual elements of an array. Use ASSIGN instead.
- A table may hold any kind of value, e.g. numbers, strings, even other tables.
- A table may have any number of dimensions, each defined by one item in the list of indices.
- integer - Specifies a numeric dimension (array) whose indices are defined from the base (1 unless you set it otherwise) to integer
- (integer1 TO integer2) - Specifies a numeric dimension (array) whose indices are defined from integer1 TO integer2
- * - Specifies a general dimension (or hash), which may be indexed by any symbol or string
- (list) - Specifies an enumerated dimension whose indices come solely from the strings or symbols in the given list
- If the AS option is specified, the value that follows is assigned to all elements of the newly defined table. Note that tables with general dimensions cannot be initialized.
- If the BASE integer option is specified, then the integer is used as the lowest index of the numeric dimension.
- The base can be set globally to 0 for all DEFINE operations by (ASSIGN *table-base* = 0)
- If the ADJUSTABLE option is set to TRUE (default), then the table is resized automatically if an index outside its dimension limits is given (does not apply to enumerated dimensions).
(DEFINE gene-lengths (number-of-genes)
(ASSIGN gene-lengths (3) = (LENGTH-OF (THIRD gene-list))
Presuming that the variable number-of-genes holds an integer, the statement defines a table, gene-lengths, with a single numeric dimension. The legal indices for the table are from 1 to the value of the variable number-of-genes.(DEFINE mutations (seq-length (A C G T)) AS 0)
(INCREMENT mutations (position C))
Presuming that seq-length is an integer, the statement defines a table, mutations, with one numeric dimension and a second enumerated dimension. The legal indices for the second dimension are the letters A, C, G, and T. All the elements of the table (seq-length times 4) are initialized to 0.(DEFINE gene-info ((ORTHOLOGS-OF all4312) (gene-name organism replicon start stop)))
(FOR-EACH gene IN (ORTHOLOGS-OF all4312)
DO (ASSIGN gene-info (gene replicon) = (REPLICON-OF gene))
The statement defines a table, gene-info, with two enumerated dimensions. The legal indices for the first dimension are the gene names of all4312 orthologs. The legal indices for the second dimension are gene-name, organism, etc.(DEFINE log-ratio-bin ((-10 TO +10)) AS 0 ADJUSTABLE false)
(FOR-EACH log-ratio IN log-ratio-set
AS bin = (APPROX log-ratio)
DO (INCREMENT log-ratio-bin (bin))
The statement defines a table, log-ratio-bin, with one numeric dimension. The legal indices for the dimension are the integers from -10 to +10. Since the table is set as nonadjustable, if any future statement tries to use an index outside this range, an error will be raised. All 21 of the elements of the table are initialized to 0.(DEFINE telephone-directory (* (work home cell)))
(ASSIGN telephone-directory (Turing cell) = 1-234-567-8900)
The statement defines a table, telephone-directory, with one general dimension and a second enumerated dimension. The legal indices for the second dimension are work, home, and cell.