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
# PMAT-502ab (Tranche 2): filter(lambda p: pred, xs) -> materialized list of
# elements where the Bool predicate holds (order-preserving).
def positives(xs: list[int]) -> list[int]:
    return list(filter(lambda x: x > 0, xs))


def evens(xs: list[int]) -> list[int]:
    return list(filter(lambda x: x % 2 == 0, xs))


def nonempty(words: list[str]) -> list[str]:
    return list(filter(lambda w: len(w) > 0, words))