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
# PMAT-502l (Tranche 2): more string methods — lstrip/rstrip (Str) and
# find/count (Int).
def trim_left(s: str) -> str:
    return s.lstrip()


def trim_right(s: str) -> str:
    return s.rstrip()


def index_of(s: str, sub: str) -> int:
    return s.find(sub)


def occurrences(s: str, sub: str) -> int:
    return s.count(sub)