aboutsummaryrefslogtreecommitdiff
path: root/examples/hello.sloth
blob: db71b01e065948f8f89ba2cfc3c6b931d7102bd2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
fn test() [Int] {
    var list: [Int] = [500, 5, 7];

    vpushi(list, 3);
    vpushi(list, 3);
    vpushi(list, 3);
    vpushi(list, 5);

    var x: Int = vpopi(list);
    vpushi(list, x);
    vpushi(list, x * 2);
    vpushi(list, x * 3);

    return list;
}

fn testtwo(list: [Int]) Int {
    #vpopi(list);
    var x: Int = vpopi(list);
    return x;
}

fn testthree(list: [Int]) Int {
    var x: Int = vlen(list);
    return x;
}

foreign fn testback(x: Int) Void;

fn testfour(list: [Int]) Int {
    vseti(list, 0, 888);
    var i: Int = 0;
    while i < vlen(list) {
        var value: Int = vgeti(list, i);
        testback(value);
        i = i + 1;
    }
    return 0;
}