# Functions whose results are managed values (str, a list of str, a dict, a tuple holding a
# str, a dataclass), from this module and another, run in memory as the native build runs
# them.
import labels
from labels import label, name_of


def local(n: int) -> str:
    return "loc" + str(n)


# (a conditional expression of str results: the result of the branch not taken is never made)
def pick(n: int) -> str:
    return label(n) + "!" if n > 0 else name_of(n)


def words(n: int) -> list[str]:
    out: list[str] = []
    for i in range(n):
        out.append("w" + str(i))
    return out


def ages() -> dict[str, int]:
    d: dict[str, int] = {}
    d["a"] = 1
    d["b"] = 2
    return d


def pair(n: int) -> tuple[str, int]:
    return ("p" + str(n), n)


def main() -> None:
    print(label(1))
    for i in range(3):
        print(label(i), name_of(i), local(i))
    s: str = name_of(-1)
    print(s)
    print(f"{label(1)}-{local(5)}")
    ws: list[str] = words(3)
    print(len(ws), ws[0], ws[2])
    d: dict[str, int] = ages()
    print(d["a"] + d["b"], len(d))
    t, k = pair(7)
    print(t, k)
    p: labels.Person = labels.make_person(9)
    print(p.name, p.age)
    print(pick(1), pick(0), pick(2) + pick(-1))
