summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2022-12-07 00:33:16 +0100
committerLeah Neukirchen <leah@vuxu.org>2022-12-07 00:33:44 +0100
commit3119e2a2b550919326f7850242a6083c81a9b1fa (patch)
treef51aab3495b5b70b1f8f61af616afe3fcff088ed
parentcb824d94d9d5a81acb498b6b9462a318ac4d23aa (diff)
downloadmew-3119e2a2b550919326f7850242a6083c81a9b1fa.tar.gz
mew-3119e2a2b550919326f7850242a6083c81a9b1fa.tar.xz
mew-3119e2a2b550919326f7850242a6083c81a9b1fa.zip
app: allow empty arguments
-rw-r--r--mew.scm8
-rw-r--r--mew.svnwiki2
-rw-r--r--tests/test.mew6
3 files changed, 13 insertions, 3 deletions
diff --git a/mew.scm b/mew.scm
index 5828f36..17c23d2 100644
--- a/mew.scm
+++ b/mew.scm
@@ -1,6 +1,6 @@
 (module mew
   (export
-     act accumulate andloc at
+     act accumulate andloc app at
      boolean
      comp cross-product
      dec def del-at div
@@ -97,7 +97,6 @@
                assoc
                member)
       (lambda fun)
-      (apply app)
       (ceiling ceil)
       (truncate trunc)
       ))
@@ -179,6 +178,11 @@
             (display " "))
           (loop (cdr args) (car args))))))
 
+  (define (app f . args)
+    (if (null? args)
+      (f)
+      (apply apply f args)))
+
   (define-syntax seq
     (syntax-rules ()
       ((_)
diff --git a/mew.svnwiki b/mew.svnwiki
index c204dbb..5b0d4b0 100644
--- a/mew.svnwiki
+++ b/mew.svnwiki
@@ -157,7 +157,7 @@ Alias for {{floor-remainder}}.
 
 <procedure>(app <proc> . <args>)</procedure>
 
-Alias for {{apply}}.
+Like {{apply}}, but supports empty {{<args>}}.
 
 <syntax>(op <form>)</syntax>
 
diff --git a/tests/test.mew b/tests/test.mew
index 5587d90..32d9df1 100644
--- a/tests/test.mew
+++ b/tests/test.mew
@@ -141,6 +141,12 @@
   (test "\n" (with-output-to-string (fun () (prn))))
   (test 3 (esc ret (with-output-to-string (fun () (ret (prn 1 2 3)))))))
 
+(test-group "app"
+  (test 15 (app + '(4 5 6)))
+  (test 15 (app + 4 5 '(6)))
+  (test 15 (app + 4 5 6 '()))
+  (test 0 (app +)))
+
 (test-group "seq"
   (test #t (void? (seq)))
   (test 1 (seq 1))