From e4ccee85e607c149ae1d14d66b344ae27c4c6528 Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Sat, 20 Jan 2024 18:05:18 -0800 Subject: remove stemlib --- src/builtins.c | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/builtins.c b/src/builtins.c index 5d7752c..8a60514 100644 --- a/src/builtins.c +++ b/src/builtins.c @@ -553,6 +553,33 @@ void stemlen(value_t *v) { array_append(STACK, retval); } +/* void dip(value_t *v) { */ +/* value_t *v2 = array_pop(STACK); */ +/* if (v2 == NULL) { */ +/* eval_error("EMPTY STACK"); */ +/* return; */ +/* } */ +/* value_t *v1 = array_pop(STACK); */ +/* if (v1 == NULL) { */ +/* array_append(STACK, v2); */ +/* eval_error("EMPTY STACK"); */ +/* return; */ +/* } */ + +/* if (v2->type == VQUOTE) { */ +/* array_append(EVAL_STACK, v1); */ +/* array_append(EVAL_STACK, v2); */ +/* for (int i = 0; i < v2->quote->size; i++) { */ +/* eval(value_copy(v2->quote->items[i])); */ +/* } */ +/* value_free(array_pop(EVAL_STACK)); */ +/* array_pop(EVAL_STACK); */ +/* } else { */ +/* eval(v2); */ +/* } */ +/* array_append(STACK, v1); */ +/* } */ + void dip(value_t *v) { value_t *v2 = array_pop(STACK); if (v2 == NULL) { @@ -574,31 +601,6 @@ void dip(value_t *v) { } value_free(array_pop(EVAL_STACK)); array_pop(EVAL_STACK); - } else { - eval(v1); - } - array_append(STACK, v1); -} - -void keep(value_t *v) { - value_t *v2 = array_pop(STACK); - if (v2 == NULL) { - eval_error("EMPTY STACK"); - return; - } - value_t *v1 = array_pop(STACK); - if (v1 == NULL) { - array_append(STACK, v2); - eval_error("EMPTY STACK"); - return; - } - - if (v2->type == VQUOTE) { - array_append(EVAL_STACK, v2); - for (int i = 0; i < v2->quote->size; i++) { - eval(value_copy(v2->quote->items[i])); - } - value_free(array_pop(EVAL_STACK)); } else { eval(v2); } @@ -1169,7 +1171,6 @@ void add_funcs() { add_func(FLIT, equals, "="); add_func(FLIT, stemif, "if"); add_func(FLIT, clear, "clear"); - add_func(FLIT, keep, "keep"); add_func(FLIT, dip, "dip"); add_func(FLIT, stemlen, "len"); add_func(FLIT, quote, "quote"); -- cgit