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
18
def bool_to_int(b: bool) -> int:
    # int(True) == 1, int(False) == 0.
    return int(b)


def count_true(bs: list[bool]) -> int:
    # the canonical "count of True" idiom: sum of int(b).
    return sum(int(b) for b in bs)


def predicate_to_int(x: int) -> int:
    # int() of a comparison result.
    return int(x > 0) + int(x > 10)


def bool_to_float_scaled(b: bool) -> float:
    # float(True) == 1.0; float(bool) must cast through i64 in Rust.
    return float(b) * 2.5