diff --git a/SLS_C/src/builtin.c b/SLS_C/src/builtin.c index ddecdd4..0b08986 100644 --- a/SLS_C/src/builtin.c +++ b/SLS_C/src/builtin.c @@ -1182,8 +1182,17 @@ Boolean builtin_sqrt(InterpreterState *interpreter_state) { } Boolean builtin_swap(InterpreterState *interpreter_state) { - (void)interpreter_state; - return FALSE; + if (interpreter_state->stack == NULL) return FALSE; + if (interpreter_state->stack->next == NULL) return FALSE; + + StackItem *a = interpreter_state->stack; + StackItem *b = a->next; + + a->next = b->next; + b->next = a; + interpreter_state->stack = b; + + return TRUE; } Boolean builtin_tan(InterpreterState *interpreter_state) {