This repository has been archived on 2026-08-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
el-retired/runtime/el/strings.el
T
will d3495476f4
El SDK Release / build-and-release (push) Failing after 13m0s
kill: purge old-paradigm dist/platform binaries from tree
The generated C, amalgams, vendored runtime pins, and compiled binaries
from the Claude Code era are removed from the worktree. The El sources
survive; this tree is now source-only for the first-principles rebuild.

Per Principal direction 2026-08-19.
2026-08-19 19:46:15 -05:00

70 lines
2.0 KiB
EmacsLisp

// runtime/el/strings.el the string family, redo in El.
// Replaces the C-builtin string family with El definitions.
// Redo discipline: these define the semantics; the C stubs behind the
// seam become trampolines, then nothing.
// concat lifting: the El-level join, no C library logic
fn el_join(parts: [String], sep: String) -> String {
let n: Int = native_list_len(parts)
let out: String = ""
let i: Int = 0
while i < n {
let part: String = native_list_get(parts, i)
let out = if i == 0 { part } else { str_concat(out, str_concat(sep, part)) }
let i = i + 1
}
return out
}
// pascal-free, redone slice engine: charwise, pure El
fn el_reverse(s: String) -> String {
let n: Int = str_len(s)
let out: String = ""
let i: Int = n - 1
while i >= 0 {
let out = str_concat(out, str_slice(s, i, i + 1))
let i = i - 1
}
return out
}
// the family's centerpiece: redo of the builtin, expressed over El
fn el_ends_with(s: String, suf: String) -> Bool {
let n: Int = str_len(s)
let m: Int = str_len(suf)
if m > n { return false }
return str_eq(str_slice(s, n - m, n), suf)
}
// separator-aware split built on the above, pure El
fn el_split(s: String, sep: String) -> [String] {
let res: [String] = native_list_empty()
let n: Int = str_len(s)
let m: Int = str_len(sep)
let i: Int = 0
let start: Int = 0
while i <= n - m {
if m == 0 {
let acc: [String] = native_list_append(res, s)
return acc
}
if str_eq(str_slice(s, i, i + m), sep) {
let res = native_list_append(res, str_slice(s, start, i))
let start = i + m
let i = i + m
} else {
let i = i + 1
}
}
let res = native_list_append(res, str_slice(s, start, n))
return res
}
fn main() -> Void {
println(el_join(["a", "b", "c"], "-"))
println(el_reverse("hello"))
println(el_ends_with("neuron", "ron"))
let parts: [String] = el_split("a-b-c-d", "-")
println(el_join(parts, ","))
}