summaryrefslogtreecommitdiffhomepage
path: root/CompilerDriver/cc2/regression-tests/pure2-intro-example-three-loops.cpp2
blob: aa51ea959908258dbfa0bfc82b0a87b0dddaa4e1 (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

print: (thing:_) =
    std::cout << ">> " << thing << "\n";

decorate_and_print: (inout thing:_) = {
    thing = "[" + thing + "]";
    print(thing);
}

main: () -> int = {
    words: std::vector<std::string> =
        ( "hello", "big", "world" );
    view: std::span<std::string> = words;

    i := new<int>(0);
    while i* < view.ssize() next i*++ {
        print( view[i*] );
    }

    do {
        std::cout << std::setw(4) << "**";
    } next i*-- while i*>0;

    std::cout << "\n";
    for words do (inout word)
        decorate_and_print(word);

    print( : std::string = "end of program" );
}