aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksey Veresov <aleksey@veresov.pro>2021-01-04 15:03:31 +0300
committerAleksey Veresov <aleksey@veresov.pro>2021-01-04 15:03:31 +0300
commitae882f68193e00deebce41c32df644b6cb2f2a47 (patch)
tree336389aa597e73ebb0c75e4e08a1dd802d9acccf /src
parent0b4de175110bdf6ffaeb0ba3b86053fd2fec78be (diff)
downloadcsx-ae882f68193e00deebce41c32df644b6cb2f2a47.tar
csx-ae882f68193e00deebce41c32df644b6cb2f2a47.tar.xz
csx-ae882f68193e00deebce41c32df644b6cb2f2a47.zip
.
Diffstat (limited to 'src')
-rw-r--r--src/csx.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/csx.c b/src/csx.c
index eca55e7..3c897dd 100644
--- a/src/csx.c
+++ b/src/csx.c
@@ -360,6 +360,8 @@ static void *zip(void *params, void *values)
params = tail(params);
values = tail(values);
}
+ if (type(params) == type_name)
+ res = new_pair(new_pair(params, values), res);
return res;
}
@@ -392,6 +394,13 @@ tailcall:
res = base_do(fn->body);
context = saved;
return res;
+ } else if (type(fn) == type_pair) {
+ pair_data *res = (void *)fn;
+ int pos = *(int *)head(ops);
+ while (pos--) res = res->tail;
+ return res->head;
+ } else if (type(fn) == type_null) {
+ return null;
} else {
exit(1);
}
@@ -477,3 +486,16 @@ void *csx_dot(void *a, void *b, void *c, ...)
va_end(args);
return res;
}
+
+void *csx_str(const char *str)
+{
+ if (!initiated) init();
+ if (!str || !*str) return null;
+ pair_data *res = new_pair(csx_int(*str), null);
+ pair_data **p = (pair_data **)&res->tail;
+ while (*++str) {
+ *p = new_pair(csx_int(*str), null);
+ p = (pair_data **)&(*p)->tail;
+ }
+ return res;
+}