cfad47cfa3/t3compiler/tads3/test/data/addlist.t

4b825dc642cb6eb9a060e54bf8d69288fbee4904cfad47cfa334b206c65f22086bcc5d63e6f70944
1
#include "tads.h"
2
#include "t3.h"
3
4
_say_embed(str) { tadsSay(str); }
5
6
_main(args)
7
{
8
    t3SetSay(_say_embed);
9
    main();
10
}
11
12
showlist(lst)
13
{
14
    "[";
15
    for (local i = 1 ; i <= lst.length() ; ++i)
16
    {
17
        if (i > 1)
18
            " ";
19
        tadsSay(lst[i]);
20
    }
21
    "]";
22
}
23
24
main()
25
{
26
    local x = [];
27
28
    "initially: x = <<showlist(x)>>\n";
29
30
    x += ['one'];
31
    "after adding [one]: x = <<showlist(x)>>\n";
32
33
    x += ['two'];
34
    "after adding [two]: x = <<showlist(x)>>\n";
35
    
36
    x += ['three', 'four'];
37
    "after adding [three, four]: x = <<showlist(x)>>\n";
38
}
39