aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2019-04-06 19:01:41 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2019-04-06 19:01:41 +0200
commit0e4118cd1bde2d79e15d3b72cc9fe6044b35eccc (patch)
tree95af27d8efec6014f96b4631dc511d350f42acc9
parentAdd termios tests. (diff)
downloadcalp-0e4118cd1bde2d79e15d3b72cc9fe6044b35eccc.tar.gz
calp-0e4118cd1bde2d79e15d3b72cc9fe6044b35eccc.tar.xz
Add unval.
-rw-r--r--module/util.scm10
1 files changed, 10 insertions, 0 deletions
diff --git a/module/util.scm b/module/util.scm
index 1a7c5471..249e2de2 100644
--- a/module/util.scm
+++ b/module/util.scm
@@ -206,3 +206,13 @@
lst (iota (length lst))))
(export map-each)
+
+;; Takes a procedure returning multiple values, and returns a function which
+;; takes the same arguments as the original procedure, but only returns one of
+;; the procedures. Which procedure can be sent as an additional parameter.
+(define* (unval proc #:optional (n 0))
+ (lambda args
+ (call-with-values (lambda () (apply proc args))
+ (lambda args (list-ref args n)))))
+
+(export unval)