emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 209/255: adding curry, rcurry and compose helpers


From: Eric Schulte
Subject: [elpa] 209/255: adding curry, rcurry and compose helpers
Date: Sun, 16 Mar 2014 01:02:50 +0000

eschulte pushed a commit to branch go
in repository elpa.

commit cdaf1a77bc87a10dc12baa795679adc8b4adb6bc
Author: Eric Schulte <address@hidden>
Date:   Tue Aug 6 12:13:55 2013 -0600

    adding curry, rcurry and compose helpers
---
 go-util.el |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/go-util.el b/go-util.el
index 4483369..45b7049 100644
--- a/go-util.el
+++ b/go-util.el
@@ -28,6 +28,24 @@
 ;;; Code:
 (eval-when-compile (require 'cl))
 
+(defun curry (function &rest arguments)
+  (lexical-let ((function function)
+                (arguments arguments))
+    (lambda (&rest more) (apply function (append arguments more)))))
+
+(defun rcurry (function &rest arguments)
+  (lexical-let ((function function)
+                (arguments arguments))
+    (lambda (&rest more) (apply function (append more arguments)))))
+
+(defun compose (function &rest more-functions)
+  (cl-reduce (lambda (f g)
+               (lexical-let ((f f) (g g))
+                 (lambda (&rest arguments)
+                   (funcall f (apply g arguments)))))
+             more-functions
+             :initial-value function))
+
 (defun rcons (x lst)
   (append lst (list x)))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]