xpile 0.1.615

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
14
15
16
17
# PMAT-715: `xs[i].pop()` must mutate the inner container IN PLACE. The read path
# cloned `xs[i]` and popped the clone, so `xs[i]` kept its length (silent-wrong:
# the popped VALUE was correct but the side-effect was lost). Now emits an l-value
# pop over a `mut` base, with negative-index wrapping.
def pop_inner(xs: list[list[int]]) -> int:
    v = xs[0].pop()
    return v * 10 + len(xs[0])


def pop_neg(xs: list[list[int]]) -> int:
    v = xs[-1].pop()
    return v + len(xs[-1])


def plain_pop(xs: list[int]) -> int:
    v = xs.pop()
    return v + len(xs)