User Tools

Site Tools


at:tutorial:basic

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
at:tutorial:basic [2007/04/04 09:18] – * elisagat:tutorial:basic [2007/04/04 10:56] elisag
Line 33: Line 33:
 ==== Tables ==== ==== Tables ====
  
-As in Pico, indexed tables represent what other languages call arrays or lists. Tables indexes range from 1 to the size of the table. As variables, one can define, assign and refer to a table. Table definition is also made  with the keyword **def** in the following form:+As in Pico, indexed tables represent what other languages call arrays or lists. Tables are unidimensional and their indexes range from 1 to the size of the table. As variables, one can define, assign and refer to a table. Table definition is also made  with the keyword **def** in the following form:
 <code> <code>
 def t[ <size> ] { <expression> } def t[ <size> ] { <expression> }
Line 41: Line 41:
 >def z := 0 >def z := 0
 >>0 >>0
->def t[5] { z := z + 1 }+>def table[5] { z := z + 1 }
 >>[1, 2, 3, 4, 5] >>[1, 2, 3, 4, 5]
 </code> </code>
-Table entries can also contain another tables. -TOADD_1+Although there is no special constructor for definition of multidimensional tables, a table entry can contain another table. This is internally stored as a unidimensional table whose entries are other tables. 
 + 
 +<code> 
 +>def vocals := [1, t, "a", "e", "i", "o", "u"
 +>>["a", "e", "i", "o", "u"
 +>t[3] := vocals; 
 +>>[1, 2, ["a", "e", "i", "o", "u"], 4, 5] 
 +>t[3][2] 
 +>>"e" 
 +</code> 
 + 
 +As shown in the definition of the varible "vocals", evaluating a series of comma-separated abstract grammar values between square brackets (aka a tabulation) results in a table.
  
 ==== Functions ==== ==== Functions ====
at/tutorial/basic.txt · Last modified: 2020/02/09 22:05 by elisag