From ae882f68193e00deebce41c32df644b6cb2f2a47 Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Mon, 4 Jan 2021 15:03:31 +0300 Subject: . --- src/csx.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/csx.c') 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; +} -- cgit v1.2.3