at:tutorial:basic
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
at:tutorial:basic [2007/04/04 09:10] – elisag | at:tutorial:basic [2007/04/04 10:56] – elisag | ||
---|---|---|---|
Line 11: | Line 11: | ||
==== Variables ==== | ==== Variables ==== | ||
- | As usual, one can define, assign and refer to a variable. Variable definitions are made with the keyword def. Note that AmbientTalk is a dynamically typed language so, variables do not have a type but, they just contain values. | + | As usual, one can define, assign and refer to a variable. Variable definitions are made with the keyword |
In the examples we use the interactive AmbientTalk shell (iat) where the input and output prompt are represented by > and >> , respectively. | In the examples we use the interactive AmbientTalk shell (iat) where the input and output prompt are represented by > and >> , respectively. | ||
Line 24: | Line 24: | ||
Variable definitions can be combined with assignments as shown above. As in Pico, assignments uses the ": | Variable definitions can be combined with assignments as shown above. As in Pico, assignments uses the ": | ||
- | An assignment consists of one or more expressions, | + | An assignment consists of one or more expressions, |
< | < | ||
>[x, y] := [ y, x ] | >[x, y] := [ y, x ] | ||
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 made also with the keyword def in the following form: | + | As in Pico, indexed tables represent what other languages call arrays or lists. Tables |
< | < | ||
def t[ < | def t[ < | ||
Line 41: | Line 41: | ||
>def z := 0 | >def z := 0 | ||
>>0 | >>0 | ||
- | > | + | > |
>>[1, 2, 3, 4, 5] | >>[1, 2, 3, 4, 5] | ||
</ | </ | ||
- | Table entries | + | Although there is no special constructor for definition of multidimensional tables, a table entry can contain another |
+ | |||
+ | <code> | ||
+ | >def vocals := [1, t, " | ||
+ | >> | ||
+ | >t[3] := vocals; | ||
+ | >>[1, 2, [" | ||
+ | > | ||
+ | >>" | ||
+ | </ | ||
+ | |||
+ | As shown in the definition of the varible " | ||
==== Functions ==== | ==== Functions ==== |
at/tutorial/basic.txt · Last modified: 2020/02/09 22:05 by elisag