summaryrefslogtreecommitdiff
path: root/lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 813703c..413c60b 100644
--- a/lib.c
+++ b/lib.c
@@ -116,6 +116,12 @@ static Val fn_spend(State *S, int nargs, Val *args) {
}
return VAL_OBJ(objstring_take(S, new, len));
}
+static Val fn_spendsplat(State *S, int nargs, Val *args) {
+ CHECK(nargs==1, "need exactly 1 arg for spendsplat");
+ CHECK(IS_ARR(args[0]), "need arr arg for spendsplat");
+ ObjArr *a = AS_ARR(args[0]);
+ return fn_spend(S, a->len, a->d);
+}
static Val fn_ssplit(State *S, int nargs, Val *args) {
CHECK(nargs==2,"need exactly 2 args for ssplit");
CHECK(IS_STRING(args[0]) && IS_STRING(args[1]), "need two strings for ssplit");
@@ -196,6 +202,7 @@ static BuiltinFunc builtin_funcs[] = {
{ "#", fn_len },
{ ",", fn_pend },
{ "s,", fn_spend },
+ { "s,@", fn_spendsplat },
{ "ssplit", fn_ssplit },
{ "schars-ascii", fn_schars_ascii },