summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2022-10-31 22:25:45 +0100
committerLeah Neukirchen <leah@vuxu.org>2022-10-31 22:25:45 +0100
commit7f98ae1710bfd34d9111f8e8d7e6b358590fec3a (patch)
tree7ef23ac989fc1cd4836b66bbf5fc4ba7b613faae
parentce1d1d5d8de9eda8f65233c9ae956e60599aab34 (diff)
downloadmew-7f98ae1710bfd34d9111f8e8d7e6b358590fec3a.tar.gz
mew-7f98ae1710bfd34d9111f8e8d7e6b358590fec3a.tar.xz
mew-7f98ae1710bfd34d9111f8e8d7e6b358590fec3a.zip
add juxt, unlist
-rw-r--r--mew.scm10
-rw-r--r--mew.svnwiki9
2 files changed, 18 insertions, 1 deletions
diff --git a/mew.scm b/mew.scm
index 781cacb..edb14bc 100644
--- a/mew.scm
+++ b/mew.scm
@@ -7,6 +7,7 @@
      fin final for fun*
      gen generic-for-each genumerate get gfix giterate gmatch group-by-accumulator gslice-when gsplit gwindow
      inc inject into
+     juxt
      keys
      len loc
      mod
@@ -17,7 +18,7 @@
      sing? set str slurp
      tally-accumulator tbl time
      while
-     until
+     unlist until
      vals
      -> fun-> fun->> set->
      <>?
@@ -636,4 +637,11 @@
     (match l
       ((_) #t)
       (_   #f)))
+
+  (define (unlist args)
+    (apply values args))
+
+  (define (juxt . fs)
+    (lambda args
+      (unlist (map (lambda (f) (apply f args)) fs))))
 )
diff --git a/mew.svnwiki b/mew.svnwiki
index ef27a3f..9a75f5b 100644
--- a/mew.svnwiki
+++ b/mew.svnwiki
@@ -141,6 +141,15 @@ Alias for {{compose}}.
 
 Reverse function composition.
 
+<procedure>(juxt <fun>...)</procedure>
+
+Returns a function that applies each {{<fun>}} to its arguments and
+returns the results as multiple values.
+
+<procedure>(unlist <list>)</procedure>
+
+Returns the list {{<list>}} as multiple values.
+
 <procedure>(str . <args>)</procedure>
 
 Returns a new string composed by concatenating the strings given by