xpile 0.1.616

Polyglot transpile workbench (Python/C/C++/Rust/Ruchy/Lean ↔ Rust/Ruchy/PTX/WGSL/SPIR-V) with provable contracts at every layer.
1
2
3
4
5
6
7
8
9
10
11
12
13
# PMAT-502ax (Tranche 2): dict get-or-insert d.setdefault(k, default).
def getset(d: dict[str, int], k: str) -> int:
    return d.setdefault(k, 0)


def getset_present(d: dict[str, int], k: str) -> int:
    return d.setdefault(k, 99)


def local_setdefault() -> int:
    d: dict[str, int] = {}
    x = d.setdefault("a", 5)
    return x + len(d)