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
# PMAT-501b (Tranche 2): set comprehension {e for x in xs}.
# Materialises to s = set(); for x in xs: s.add(e).
def distinct_doubles(xs: list[int]) -> int:
    s = {x * 2 for x in xs}
    return len(s)


def has_square(xs: list[int], q: int) -> bool:
    squares = {x * x for x in xs}
    return q in squares