Landin library reference discuss source

compiler/tests/fixtures/runtime/library-shared-tree/main.ldn

1import core/mem
2import core/tree
3
4exercise: () -> (ok: bool) ! mem.not_found =
5    ok = false
6    value := tree.new()
7    return when tree.length(value) <> 0 or tree.ordinal(tree.id(usize(42))) <> 42
8    _ = tree.get(value, tree.id(usize(0))) else (problem)
9        ok = problem == mem.not_found
10        return
11    end
12end exercise
13
14public main: () -> (code: i32) =
15    code = 1
16    ok := exercise() else false
17    if ok then
18        code = 42
19    end if
20end main