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
# PMAT-644: str.rsplit(sep, maxsplit) — split from the RIGHT, capping at maxsplit
# splits, parts in left-to-right order (like Python). Common for splitting off
# the last component (`name.rsplit(".", 1)`).
def last_two(s: str) -> str:
    return "|".join(s.rsplit("/", 2))


def strip_ext(s: str) -> str:
    return s.rsplit(".", 1)[0]


def no_limit(s: str) -> str:
    return "|".join(s.rsplit(".", -1))  # negative maxsplit = all parts


# bare rsplit(sep) is identical to split(sep) (regression).
def bare(s: str) -> int:
    return len(s.rsplit("."))