From 2750e54a2ad5afeabb7093fc10e9fb686b6f6059 Mon Sep 17 00:00:00 2001 From: Preston Pan Date: Mon, 22 Jan 2024 18:34:19 -0800 Subject: add unglue --- src/stem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/stem.c') diff --git a/src/stem.c b/src/stem.c index 5c2e379..f5a13ad 100644 --- a/src/stem.c +++ b/src/stem.c @@ -39,15 +39,15 @@ void array_append(array_t *a, value_t *v) { a->size++; } -void array_curry(array_t *a, value_t *v) { +void array_add(array_t *a, value_t *v, int index) { if (a->size >= a->capacity - 3) { a->capacity = a->capacity * 2; a->items = realloc(a->items, a->capacity * sizeof(value_t *)); } - for (int i = a->size - 1; i >= 0; i--) { + for (int i = a->size - 1; i >= index; i--) { a->items[i + 1] = a->items[i]; } - a->items[0] = v; + a->items[index] = v; a->size++; } -- cgit