Archived
d3495476f4
El SDK Release / build-and-release (push) Failing after 13m0s
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.
127 lines
4.2 KiB
C
127 lines
4.2 KiB
C
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
#include "el_runtime.h"
|
|
|
|
el_val_t el_join(el_val_t parts, el_val_t sep);
|
|
el_val_t el_reverse(el_val_t s);
|
|
el_val_t el_ends_with(el_val_t s, el_val_t suf);
|
|
el_val_t el_split(el_val_t s, el_val_t sep);
|
|
|
|
static el_val_t __el_body_el_join(el_val_t parts, el_val_t sep) {
|
|
el_val_t n = native_list_len(parts);
|
|
el_val_t out = EL_STR("");
|
|
el_val_t i = 0;
|
|
while (i < n) {
|
|
el_val_t part = native_list_get(parts, i);
|
|
out = ({ el_val_t _if_result_1 = 0; if ((i == 0)) { _if_result_1 = (part); } else { _if_result_1 = (str_concat(out, str_concat(sep, part))); } _if_result_1; });
|
|
i = (i + 1);
|
|
}
|
|
return out;
|
|
return 0;
|
|
}
|
|
struct __env_el_join { el_val_t parts; el_val_t sep; };
|
|
static el_val_t __thunk_el_join(void* __v) {
|
|
struct __env_el_join* __e = (struct __env_el_join*)__v; (void)__e;
|
|
return __el_body_el_join(__e->parts, __e->sep);
|
|
}
|
|
el_val_t el_join(el_val_t parts, el_val_t sep) {
|
|
{ el_val_t __s = el_seam_run(EL_STR("el_join"), 0, 0); if (__s) return __s; }
|
|
struct __env_el_join __env = { parts, sep };
|
|
el_val_t __r = el_seam_wrap(EL_STR("el_join"), __thunk_el_join, &__env);
|
|
__r = el_seam_run(EL_STR("el_join"), 1, __r);
|
|
return __r;
|
|
}
|
|
|
|
static el_val_t __el_body_el_reverse(el_val_t s) {
|
|
el_val_t n = str_len(s);
|
|
el_val_t out = EL_STR("");
|
|
el_val_t i = (n - 1);
|
|
while (i >= 0) {
|
|
out = str_concat(out, str_slice(s, i, (i + 1)));
|
|
i = (i - 1);
|
|
}
|
|
return out;
|
|
return 0;
|
|
}
|
|
struct __env_el_reverse { el_val_t s; };
|
|
static el_val_t __thunk_el_reverse(void* __v) {
|
|
struct __env_el_reverse* __e = (struct __env_el_reverse*)__v; (void)__e;
|
|
return __el_body_el_reverse(__e->s);
|
|
}
|
|
el_val_t el_reverse(el_val_t s) {
|
|
{ el_val_t __s = el_seam_run(EL_STR("el_reverse"), 0, 0); if (__s) return __s; }
|
|
struct __env_el_reverse __env = { s };
|
|
el_val_t __r = el_seam_wrap(EL_STR("el_reverse"), __thunk_el_reverse, &__env);
|
|
__r = el_seam_run(EL_STR("el_reverse"), 1, __r);
|
|
return __r;
|
|
}
|
|
|
|
static el_val_t __el_body_el_ends_with(el_val_t s, el_val_t suf) {
|
|
el_val_t n = str_len(s);
|
|
el_val_t m = str_len(suf);
|
|
if (m > n) {
|
|
return 0;
|
|
}
|
|
return str_eq(str_slice(s, (n - m), n), suf);
|
|
return 0;
|
|
}
|
|
struct __env_el_ends_with { el_val_t s; el_val_t suf; };
|
|
static el_val_t __thunk_el_ends_with(void* __v) {
|
|
struct __env_el_ends_with* __e = (struct __env_el_ends_with*)__v; (void)__e;
|
|
return __el_body_el_ends_with(__e->s, __e->suf);
|
|
}
|
|
el_val_t el_ends_with(el_val_t s, el_val_t suf) {
|
|
{ el_val_t __s = el_seam_run(EL_STR("el_ends_with"), 0, 0); if (__s) return __s; }
|
|
struct __env_el_ends_with __env = { s, suf };
|
|
el_val_t __r = el_seam_wrap(EL_STR("el_ends_with"), __thunk_el_ends_with, &__env);
|
|
__r = el_seam_run(EL_STR("el_ends_with"), 1, __r);
|
|
return __r;
|
|
}
|
|
|
|
static el_val_t __el_body_el_split(el_val_t s, el_val_t sep) {
|
|
el_val_t res = native_list_empty();
|
|
el_val_t n = str_len(s);
|
|
el_val_t m = str_len(sep);
|
|
el_val_t i = 0;
|
|
el_val_t start = 0;
|
|
while (i <= (n - m)) {
|
|
if (m == 0) {
|
|
el_val_t acc = native_list_append(res, s);
|
|
return acc;
|
|
}
|
|
if (str_eq(str_slice(s, i, (i + m)), sep)) {
|
|
res = native_list_append(res, str_slice(s, start, i));
|
|
start = (i + m);
|
|
i = (i + m);
|
|
} else {
|
|
i = (i + 1);
|
|
}
|
|
}
|
|
res = native_list_append(res, str_slice(s, start, n));
|
|
return res;
|
|
return 0;
|
|
}
|
|
struct __env_el_split { el_val_t s; el_val_t sep; };
|
|
static el_val_t __thunk_el_split(void* __v) {
|
|
struct __env_el_split* __e = (struct __env_el_split*)__v; (void)__e;
|
|
return __el_body_el_split(__e->s, __e->sep);
|
|
}
|
|
el_val_t el_split(el_val_t s, el_val_t sep) {
|
|
{ el_val_t __s = el_seam_run(EL_STR("el_split"), 0, 0); if (__s) return __s; }
|
|
struct __env_el_split __env = { s, sep };
|
|
el_val_t __r = el_seam_wrap(EL_STR("el_split"), __thunk_el_split, &__env);
|
|
__r = el_seam_run(EL_STR("el_split"), 1, __r);
|
|
return __r;
|
|
}
|
|
|
|
int main(int _argc, char** _argv) {
|
|
el_runtime_init_args(_argc, _argv);
|
|
println(el_join(el_list_new(3, EL_STR("a"), EL_STR("b"), EL_STR("c")), EL_STR("-")));
|
|
println(el_reverse(EL_STR("hello")));
|
|
println(el_ends_with(EL_STR("neuron"), EL_STR("ron")));
|
|
el_val_t parts = el_split(EL_STR("a-b-c-d"), EL_STR("-"));
|
|
println(el_join(parts, EL_STR(",")));
|
|
return 0;
|
|
}
|
|
|