summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2022-11-03 20:16:15 +0100
committerLeah Neukirchen <leah@vuxu.org>2022-11-03 20:16:15 +0100
commit86844e3db77c52cfff703c6e31ce7877e3fe0bba (patch)
tree9cc2861314c4fe47478e7d1ac02e1a3b6e04fa56
parent7a469b8d057464a1953f6b02b36ea3d5626c42fa (diff)
downloadmew-86844e3db77c52cfff703c6e31ce7877e3fe0bba.tar.gz
mew-86844e3db77c52cfff703c6e31ce7877e3fe0bba.tar.xz
mew-86844e3db77c52cfff703c6e31ce7877e3fe0bba.zip
add void, void?
-rw-r--r--mew.scm14
-rw-r--r--mew.svnwiki8
-rw-r--r--tests/test.mew12
3 files changed, 28 insertions, 6 deletions
diff --git a/mew.scm b/mew.scm
index f4537c0..16b3479 100644
--- a/mew.scm
+++ b/mew.scm
@@ -20,7 +20,7 @@
      tally-accumulator tbl time
      while
      uniq-accumulator unlist until
-     vals
+     vals void?
      -> fun-> fun->> set->
      <>?
      ~?
@@ -65,9 +65,10 @@
 
   (reexport
     (only (chicken base)
+      rec
       unless
-      when
-      rec))
+      void
+      when))
 
   (reexport
     (only (chicken time)
@@ -320,6 +321,9 @@
 
   (define (eof) #!eof)
 
+  (define (void? x)
+    (eq? x (void)))
+
   (define (gconcatenate gen)
     (let ((gen2 #f))
       (lambda ()
@@ -391,7 +395,7 @@
     (make-unfold-generator (op #f) (op) f x))
 
   (define (gfix g)
-    (let ((prev (if #f #f)))
+    (let ((prev (void)))
       (gmap (lambda (x)
               (if (equal? prev x)
                 (eof)
@@ -401,7 +405,7 @@
             g)))
 
   (define (final g)
-    (generator-fold (lambda (x a) x) (if #f #f) g))
+    (generator-fold (lambda (x a) x) (void) g))
 
   (define-syntax and-apply
     (syntax-rules ()
diff --git a/mew.svnwiki b/mew.svnwiki
index 6a14d79..54341f0 100644
--- a/mew.svnwiki
+++ b/mew.svnwiki
@@ -199,6 +199,14 @@ Expands to a lambda expression that is true if its argument is
 
 Return true iff {{<list>}} is a proper list of length 1.
 
+<procedure>(void <args>...)</procedure>
+
+Ignores all arguments and returns a value where {{void?}} is true.
+
+<procedure>(void? <val>)</procedure>
+
+Returns true if {{<va>}} is an unspecified value, else false.
+
 
 == I/O helpers
 
diff --git a/tests/test.mew b/tests/test.mew
index 7b6f463..4fa0351 100644
--- a/tests/test.mew
+++ b/tests/test.mew
@@ -285,7 +285,7 @@
 ; final
 (test-group "final"
   (test 3 (final (generator 1 2 3)))
-  (test #t (eq? (void) (final (generator)))))
+  (test #t (void? (final (generator)))))
 
 ; ->
 
@@ -378,4 +378,14 @@
   (test 43 (act '(6 7) (op apply * _) inc))
   (test 42 (act 42)))
 
+(test-group "void"
+  (test #t (void? (void)))
+  (test #t (void? (void 1 2 3))))
+
+(test-group "void?"
+  (test #f (void? 1))
+  (test #f (void? #f))
+  (test #t (void? (void)))
+  (test #t (void? (if #f #f))))
+
 (test-exit)