[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 85bd4e0 131/439: Add @tali713's -applify
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash 85bd4e0 131/439: Add @tali713's -applify |
Date: |
Tue, 04 Aug 2015 20:27:10 +0000 |
branch: externals/dash
commit 85bd4e0779948d75c2bfd923d144944c034ee865
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>
Add @tali713's -applify
---
README.md | 11 +++++++++++
dash.el | 5 +++++
examples.el | 4 ++++
3 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md
index 6e8a367..02bdfc0 100644
--- a/README.md
+++ b/README.md
@@ -50,6 +50,7 @@ Or you can just dump `dash.el` in your load path somewhere.
* [-contains?](#-contains-list-element) `(list element)`
* [-partial](#-partial-fn-rest-args) `(fn &rest args)`
* [-rpartial](#-rpartial-fn-rest-args) `(fn &rest args)`
+* [-applify](#-applify-fn) `(fn)`
* [->](#--x-optional-form-rest-more) `(x &optional form &rest more)`
* [->>](#--x-form-rest-more) `(x form &rest more)`
* [-->](#---x-form-rest-more) `(x form &rest more)`
@@ -506,6 +507,16 @@ Requires Emacs 24 or higher.
(funcall (-rpartial '- 5 2) 10) ;; => 3
```
+### -applify `(fn)`
+
+Changes an n-arity function `fn` to a 1-arity function that
+expects a list with n items as arguments
+
+```cl
+(-map (-applify '+) '((1 1 1) (1 2 3) (5 5 5))) ;; => '(3 6 15)
+(-map (-applify (lambda (a b c) (\` ((\, a) ((\, b) ((\, c))))))) '((1 1 1) (1
2 3) (5 5 5))) ;; => '((1 (1 (1))) (1 (2 (3))) (5 (5 (5))))
+```
+
### -> `(x &optional form &rest more)`
Threads the expr through the forms. Inserts `x` as the second
diff --git a/dash.el b/dash.el
index a5e40bb..30106c2 100644
--- a/dash.el
+++ b/dash.el
@@ -473,6 +473,11 @@ Requires Emacs 24 or higher."
`(closure (t) (&rest args)
(apply ',fn (append args ',args))))
+(defun -applify (fn)
+ "Changes an n-arity function FN to a 1-arity function that
+expects a list with n items as arguments"
+ (apply-partially 'apply fn))
+
(defmacro -> (x &optional form &rest more)
"Threads the expr through the forms. Inserts X as the second
item in the first form, making a list of it if it is not a list
diff --git a/examples.el b/examples.el
index 14b38e1..05738ee 100644
--- a/examples.el
+++ b/examples.el
@@ -206,6 +206,10 @@
(funcall (-rpartial '- 5) 8) => 3
(funcall (-rpartial '- 5 2) 10) => 3))
+(defexamples -applify
+ (-map (-applify '+) '((1 1 1) (1 2 3) (5 5 5))) => '(3 6 15)
+ (-map (-applify (lambda (a b c) `(,a (,b (,c))))) '((1 1 1) (1 2 3) (5 5
5))) => '((1 (1 (1))) (1 (2 (3))) (5 (5 (5)))))
+
(defexamples ->
(-> "Abc") => "Abc"
(-> "Abc" (concat "def")) => "Abcdef"
- [elpa] externals/dash d857f73 118/439: Merge pull request #3 from rejeep/join-alias, (continued)
- [elpa] externals/dash d857f73 118/439: Merge pull request #3 from rejeep/join-alias, Phillip Lord, 2015/08/04
- [elpa] externals/dash c025efb 122/439: Add -separate (thanks @Fuco1), Phillip Lord, 2015/08/04
- [elpa] externals/dash 69e054e 124/439: Switch around order of Contribute and Contributors parts in readme., Phillip Lord, 2015/08/04
- [elpa] externals/dash 8f91ec8 126/439: 1.0.2, Phillip Lord, 2015/08/04
- [elpa] externals/dash f034c16 119/439: Add -union (thanks to @Fuco1), Phillip Lord, 2015/08/04
- [elpa] externals/dash 5e72ff9 120/439: Include numbers in github ids., Phillip Lord, 2015/08/04
- [elpa] externals/dash a23aa4b 128/439: Add examples for -group-by, Phillip Lord, 2015/08/04
- [elpa] externals/dash c669282 123/439: Add @Fuco1 to list of contributors., Phillip Lord, 2015/08/04
- [elpa] externals/dash 7f7ac33 130/439: Add Takafumi Arakaki to list of contributors., Phillip Lord, 2015/08/04
- [elpa] externals/dash 467dfa7 133/439: Add -map-indexed, Phillip Lord, 2015/08/04
- [elpa] externals/dash 85bd4e0 131/439: Add @tali713's -applify,
Phillip Lord <=
- [elpa] externals/dash 7e4ee06 135/439: 1.0.3, Phillip Lord, 2015/08/04
- [elpa] externals/dash 1284bc6 134/439: Move .el files out of root., Phillip Lord, 2015/08/04
- [elpa] externals/dash 1120417 127/439: Add -group-by, Phillip Lord, 2015/08/04
- [elpa] externals/dash 1c4e5d7 125/439: Remove eval from --reduce, it is evil., Phillip Lord, 2015/08/04
- [elpa] externals/dash 3044e83 129/439: Merge pull request #8 from tkf/group-by, Phillip Lord, 2015/08/04
- [elpa] externals/dash 78390f6 139/439: Merge pull request #12 from vemv/master, Phillip Lord, 2015/08/04
- [elpa] externals/dash 0731333 140/439: Add @vemv to list of contributors, Phillip Lord, 2015/08/04
- [elpa] externals/dash 002e4cd 132/439: Add tali713 to list of contributors., Phillip Lord, 2015/08/04
- [elpa] externals/dash 98a82ca 142/439: DRY up -repeat with --dotimes, Phillip Lord, 2015/08/04
- [elpa] externals/dash 8fe15ed 141/439: Group -repeat with -dotimes, Phillip Lord, 2015/08/04