summary refs log tree commit diff
path: root/mew.scm
diff options
context:
space:
mode:
Diffstat (limited to 'mew.scm')
-rw-r--r--mew.scm22
1 files changed, 21 insertions, 1 deletions
diff --git a/mew.scm b/mew.scm
index 845a16e..f170273 100644
--- a/mew.scm
+++ b/mew.scm
@@ -16,7 +16,7 @@
      mod
      negate nth-accumulator
      odometer one-of op op*
-     per prn proj puts
+     per pop! prn proj push! puts
      rand range rep
      sample scan scan-right sing? search seq set set-at sgn
      shuffle shuffle! str slurp
@@ -1077,6 +1077,26 @@
       ((_ location n)
        (set location (- location n)))))
 
+  (define-syntax push!
+    (syntax-rules ()
+      ((_ location x)
+       (set location (cons x location)))))
+
+  (define-syntax pop!
+    (syntax-rules ()
+      ((_ location)
+       (if (null? location)
+         (error "pop from empty list")
+         (let ((r (car location)))
+           (set! location (cdr location))
+           r)))
+      ((_ location default)
+       (if (null? location)
+         default
+         (let ((r (car location)))
+           (set! location (cdr location))
+           r)))))
+
   (define (and=> x . fs)
     (and x
          (if (null? fs)