diff options
author | Aleksey Veresov <aleksey@veresov.pro> | 2021-01-04 15:03:31 +0300 |
---|---|---|
committer | Aleksey Veresov <aleksey@veresov.pro> | 2021-01-04 15:03:31 +0300 |
commit | ae882f68193e00deebce41c32df644b6cb2f2a47 (patch) | |
tree | 336389aa597e73ebb0c75e4e08a1dd802d9acccf /src/csx.c | |
parent | 0b4de175110bdf6ffaeb0ba3b86053fd2fec78be (diff) | |
download | csx-ae882f68193e00deebce41c32df644b6cb2f2a47.tar csx-ae882f68193e00deebce41c32df644b6cb2f2a47.tar.xz csx-ae882f68193e00deebce41c32df644b6cb2f2a47.zip |
.
Diffstat (limited to 'src/csx.c')
-rw-r--r-- | src/csx.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -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; +} |