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
14
15
16
17
18
def invert(a: int) -> int:
    # Python ~a == -(a+1) == Rust !a on a signed int.
    return ~a


def invert_expr(a: int, b: int) -> int:
    # ~ over a bitwise sub-expression.
    return ~(a & b)


def double_invert(a: int) -> int:
    # ~~a == a.
    return ~~a


def mask_complement(n: int) -> int:
    # A realistic use: clear-low-bits via ~mask.
    return n & ~7