From ae7d8543305e41eaf02d43dff9f947b361489ba2 Mon Sep 17 00:00:00 2001 From: sforman Date: Fri, 11 Aug 2023 20:38:01 -0700 Subject: [PATCH] swap --- implementations/scheme-chicken/joy.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/implementations/scheme-chicken/joy.scm b/implementations/scheme-chicken/joy.scm index c3c32eb..820cc7f 100644 --- a/implementations/scheme-chicken/joy.scm +++ b/implementations/scheme-chicken/joy.scm @@ -53,6 +53,7 @@ ((is-it? "pop") (values (cdr stack) expression dict)) ((is-it? "stack") (values (cons stack stack) expression dict)) ((is-it? "swaack") (values (cons (cdr stack) (car stack)) expression dict)) + ((is-it? "swap") (values (cons (cadr stack) (cons (car stack) (cddr stack))) expression dict)) ((hash-table-exists? dict symbol) (values stack (append (hash-table-ref dict symbol) expression) dict)) (else (error "Unknown word.")))) @@ -135,6 +136,6 @@ (hash-table-set! dict (car def_list) (cdr def_list)))) -(display (doit "1 2 3 [4 5 6] swaack pop stack")) +(display (doit "1 2 3 [4 5 6] swaack pop swap stack")) (newline) -- 2.11.0