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
# PMAT-697: a float operand of `and`/`or` is truthy iff `!= 0.0` (IEEE-754 exact:
# -0.0 falsy, nan/inf truthy). Enables `if x and ...` (bool context) and the
# value-return forms `x or default` / `x and y` over float idents. These were all
# rejected ("operands of and/or must be Bool — no int-truthiness").
def or_default(x: float) -> float:
    return x or 9.0


def and_val(x: float, y: float) -> float:
    return x and y


def in_cond(x: float, y: float) -> float:
    if x and y > 1.0:
        return y
    return -1.0