aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcolin <colin@cicadas.surf>2023-02-28 20:36:19 -0800
committercolin <colin@cicadas.surf>2023-02-28 20:36:19 -0800
commit501dfc88435354a8fbb12cd8aaccddf9615dc5ff (patch)
tree4d62ac7466745bc5d33b0b145d4c8b31e7c4b301
parentb4c1525e4c93e8e277e9484a4ae3669007e86712 (diff)
added rev
-rw-r--r--hofs.lisp9
-rw-r--r--package.lisp1
2 files changed, 10 insertions, 0 deletions
diff --git a/hofs.lisp b/hofs.lisp
index 7f7afce..e8bdbc4 100644
--- a/hofs.lisp
+++ b/hofs.lisp
@@ -27,3 +27,12 @@ returning a list of return values."
(lambda (&rest args)
(loop :for fn :in (cons fn1 fns)
:collect (apply fn args))))
+
+
+(defun rev (fn)
+ "Return a function that applies its arguments to FN in reverse order.
+
+E.g. (funcall (rev #'cons) 1 2) ;; (2 . 1)"
+ (lambda (&rest args)
+ (apply fn (reverse args))))
+
diff --git a/package.lisp b/package.lisp
index 45c1374..280a253 100644
--- a/package.lisp
+++ b/package.lisp
@@ -4,5 +4,6 @@
(:use #:cl)
(:export #:closure
#:mapped
+ #:rev
#:lambda-if
#:lambda-cond))