← All examples

Argument words

Every argument after the first says its role: the first, the thing worked on, is bare; each other starts with a word.

argument_words.zg
# Every argument after the first says its role (owner, 2026-10-14): the first, the thing worked on, is bare;
# each other starts with a word. The list is `spellings.zv`'s `calls`.
fn add ['a': int32, 'b': int32] -> int32 { return 'a' plus 'b'; }

MAIN {
    let 'xs': list[int32] = [];
    list.append[lend.mut 'xs', value 3];
    list.append[lend.mut 'xs', value 4];
    std::print.useful[list.length[lend 'xs'], newln];

    let 'phones': map[str.utf8, int32] = map.empty;
    map.set[lend.mut 'phones', key "ann", value 5551];
    map.set[lend.mut 'phones', key "bob", value 5552];
    let 'n' := map.get[lend 'phones', key "ann"] otherwise 0;
    std::print.useful['n', " ", map.has[lend 'phones', key "bob"], newln];
    let 'gone' := map.remove[lend.mut 'phones', key "bob"] otherwise 0;
    std::print.useful['gone', " ", map.has[lend 'phones', key "bob"], newln];

    let 's' := "red,green,blue";
    std::print.useful[std::str.contains[lend 's', part "green"], " ", std::str.starts_with[lend 's', part "red"], " ", std::str.ends_with[lend 's', part "blue"], newln];
    let 'parts' := std::str.split[lend 's', at ","];
    let 'joined' := std::str.join[lend 'parts', between " and "];
    std::print.useful['joined', newln];
    std::print.useful[std::str.replace[lend 's', from ",", to "; "], newln];
}
Output
2
5551 true
5552 false
true true true
red and green and blue
red; green; blue