← All examples

Empty lists

[] with a type, and list.empty, then filled with list.append.

empty.zg
# Empty lists: `[]` with a type, and `list.empty`, then filled with `list.append`.
MAIN {
    let 'xs': list[int32] = [];
    list.append[lend.mut 'xs', value 7];
    list.append[lend.mut 'xs', value 8];
    std::print.useful['xs', " ", list.length[lend 'xs'], newln];
    let 'ys' := list.empty;
    std::print.useful[list.length[lend 'ys'], newln];
    list.append[lend.mut 'ys', value "a"];
    std::print.useful['ys', newln];
}
Output
[7, 8] 2
0
[a]