aboutsummaryrefslogtreecommitdiff
path: root/src/stem.c
diff options
context:
space:
mode:
authorPreston Pan <preston@nullring.xyz>2024-01-22 13:38:32 -0800
committerPreston Pan <preston@nullring.xyz>2024-01-22 13:38:32 -0800
commitab4eaabe940c1593ac060d91c652fcdb587786c0 (patch)
tree91589c287408cc94135885cd8ac9e811e492263d /src/stem.c
parent69b443d4de3dd0217968fd4482abc13b8988116b (diff)
fix curry
Diffstat (limited to 'src/stem.c')
-rw-r--r--src/stem.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/stem.c b/src/stem.c
index 57905cb..5c2e379 100644
--- a/src/stem.c
+++ b/src/stem.c
@@ -39,6 +39,18 @@ void array_append(array_t *a, value_t *v) {
a->size++;
}
+void array_curry(array_t *a, value_t *v) {
+ 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--) {
+ a->items[i + 1] = a->items[i];
+ }
+ a->items[0] = v;
+ a->size++;
+}
+
value_t *array_pop(array_t *a) {
if (a->size > 0) {
value_t *v = a->items[a->size - 1];