OSDN Git Service

joy-dup
authorsforman <sforman@hushmail.com>
Sat, 21 Oct 2023 19:40:30 +0000 (12:40 -0700)
committersforman <sforman@hushmail.com>
Sat, 21 Oct 2023 19:40:30 +0000 (12:40 -0700)
implementations/scheme-chicken/joy.scm

index 4c3e7a2..1029edb 100644 (file)
@@ -72,7 +72,7 @@
 
     ((bool) (joy-bool stack expression dict))
 
-    ((dup) (values (cons (car stack) stack) expression dict))
+    ((dup) (values (joy-dup stack) expression dict))
     ((pop) (values (cdr stack) expression dict))
     ((stack) (values (cons stack stack) expression dict))
     ((swaack) (values (cons (cdr stack) (car stack)) expression dict))
     (if (predicate term) (values term rest) (abort message))))
 
 (define (pop-list stack) (pop-kind stack list? "Not a list."))
-(define (pop-int stack) (pop-kind stack number? "Not an integer."))
+(define (pop-int  stack) (pop-kind stack number? "Not an integer."))
 (define (pop-bool stack) (pop-kind stack boolean? "Not a Boolean value."))
 
 
         ((list? term) (not (null? term)))
         (else #t)))
 
+(define (joy-dup stack)
+  (receive (term _) (pop-any stack) (cons term stack)))
+
+
 (define (joy-rest stack0)
   (receive (el stack) (pop-list stack0)
     (if (null-list? el)