louise
The Louise language: compiler, runtime, std, tooling
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#115 · main · 21 min 41 s
0Étoiles
0Forks
40Issues
std/string: replace (#56)
`string.replace s from to` replaces every occurrence of `from` in `s` with `to`, left to right and without overlapping (`replace "aaa" "aa" "b"` is "ba"). An empty `from` returns `s` unchanged, as `split` does with an empty separator (Rust's str::replace would insert `to` between every character instead). It is UTF-8 safe: it never combines `find`'s byte index with `slice`'s character count (#34). It is pure Louise, `join (split s from) to`, so there is no new runtime extern and no ABI change; std/string keeps having no imports. A native kernel can later replace the body behind the same signature. tests/run/string_replace.lse covers no match, empty `from` and `to`, overlap, multi-byte text in `s`, `from` and `to`, a whole-string match and matches at both ends, on both backends. Refs #38 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Parents ef22dd0
3 fichiers modifiés, 44 ajouts, 1 suppressions
docs/reference/language.md+1−1std/string.lse+9−0tests/run/string_replace.lse+34−0