xpile 0.1.1

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
# Multi-statement / multi-assignment if-branches (PMAT-005).
#
# Both branches assign `lo` AND `hi`. Pre-PMAT-005 the frontend rejected
# this. Post-PMAT-005 each name gets its own `let = if cond { ... } else { ... }`.
#
# `range_size(a, b)` returns |a - b| via min-max sorting.
def range_size(a: int, b: int) -> int:
    if a < b:
        lo = a
        hi = b
    else:
        lo = b
        hi = a
    return hi - lo