diff options
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -136,6 +136,15 @@ static Val fn_ssplit(State *S, int nargs, Val *args) { return VAL_OBJ(out); } +static Val fn_schars_ascii(State *S, int nargs, Val *args) { + CHECK(nargs==1, "need exactly 1 args for schars-ascii"); + CHECK(IS_STRING(args[0]), "need string arg for schars-ascii"); + ObjString *s = AS_STRING(args[0]); + ObjArr *a = objarr_new(S); + for (int i = 0; i < s->len; i++) + objarr_append(S, a, VAL_OBJ(objstring_copy(S, &s->d[i], 1))); + return VAL_OBJ(a); +} // math static Val fn_sin(State *S, int nargs, Val *args) { @@ -188,6 +197,7 @@ static BuiltinFunc builtin_funcs[] = { { ",", fn_pend }, { "s,", fn_spend }, { "ssplit", fn_ssplit }, + { "schars-ascii", fn_schars_ascii }, { "sin", fn_sin }, { "cos", fn_cos }, |