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 unique_count(xs: list[int]) -> int:
    # frozenset(iterable) de-duplicates, like set().
    return len(frozenset(xs))


def has_member(xs: list[int], k: int) -> bool:
    fs = frozenset(xs)
    return k in fs


def vowels_present(s: str) -> int:
    # frozenset over a list of 1-char strings.
    vowels = frozenset(["a", "e", "i", "o", "u"])
    n = 0
    for ch in s:
        if ch in vowels:
            n += 1
    return n