[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 4de2189 027/316: [Feature #185] -cut <> in first s
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dash 4de2189 027/316: [Feature #185] -cut <> in first slot is a function |
Date: |
Mon, 15 Feb 2021 15:57:18 -0500 (EST) |
branch: externals/dash
commit 4de21894c0c2fd655fd499ff6643f100383e2844
Author: Matus Goljer <matus.goljer@gmail.com>
Commit: Matus Goljer <matus.goljer@gmail.com>
[Feature #185] -cut <> in first slot is a function
This follows the Scheme SRFI 26 notation.
---
README.md | 2 +-
dash-functional.el | 31 +++++++++++++++++--------------
dev/examples.el | 1 +
3 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/README.md b/README.md
index 7ae077d..bff1a76 100644
--- a/README.md
+++ b/README.md
@@ -2340,7 +2340,7 @@ See `srfi-26` for detailed description.
```el
(funcall (-cut list 1 <> 3 <> 5) 2 4) ;; => '(1 2 3 4 5)
(-map (-cut funcall <> 5) '(1+ 1- (lambda (x) (/ 1.0 x)))) ;; => '(6 4 0.2)
-(-filter (-cut < <> 5) '(1 3 5 7 9)) ;; => '(1 3)
+(-map (-cut <> 1 2 3) (list 'list 'vector 'string)) ;; => '((1 2 3) [1 2 3]
"")
```
#### -not `(pred)`
diff --git a/dash-functional.el b/dash-functional.el
index bed5990..4bd2d6d 100644
--- a/dash-functional.el
+++ b/dash-functional.el
@@ -96,7 +96,10 @@ See SRFI-26 for detailed description."
(args (mapcar (lambda (_) (setq i (1+ i)) (make-symbol (format "D%d"
i)))
(-filter (-partial 'eq '<>) params))))
`(lambda ,args
- ,(--map (if (eq it '<>) (pop args) it) params))))
+ ,(let ((body (--map (if (eq it '<>) (pop args) it) params)))
+ (if (eq (car params) '<>)
+ (cons 'funcall body)
+ body)))))
(defun -not (pred)
"Take a unary predicate PRED and return a unary predicate
@@ -145,11 +148,11 @@ will increment indefinitely.
The closure accepts any number of arguments, which are discarded."
(let ((inc (or inc 1))
- (n (or beg 0)))
+ (n (or beg 0)))
(lambda (&rest _)
(when (or (not end) (< n end))
- (prog1 n
- (setq n (+ n inc)))))))
+ (prog1 n
+ (setq n (+ n inc)))))))
(defvar -fixfn-max-iterations 1000
"The default maximum number of iterations performed by `-fixfn'
@@ -182,18 +185,18 @@ cdr the final output from HALT-TEST.
In types: (a -> a) -> a -> a."
(let ((eqfn (or equal-test 'equal))
- (haltfn (or halt-test
- (-not
- (-counter 0 -fixfn-max-iterations)))))
+ (haltfn (or halt-test
+ (-not
+ (-counter 0 -fixfn-max-iterations)))))
(lambda (x)
(let ((re (funcall fn x))
- (halt? (funcall haltfn x)))
- (while (and (not halt?) (not (funcall eqfn x re)))
- (setq x re
- re (funcall fn re)
- halt? (funcall haltfn re)))
- (if halt? (cons 'halted halt?)
- re)))))
+ (halt? (funcall haltfn x)))
+ (while (and (not halt?) (not (funcall eqfn x re)))
+ (setq x re
+ re (funcall fn re)
+ halt? (funcall haltfn re)))
+ (if halt? (cons 'halted halt?)
+ re)))))
(defun -prodfn (&rest fns)
"Take a list of n functions and return a function that takes a
diff --git a/dev/examples.el b/dev/examples.el
index ade7eab..c846d08 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -1092,6 +1092,7 @@ new list."
(defexamples -cut
(funcall (-cut list 1 <> 3 <> 5) 2 4) => '(1 2 3 4 5)
(-map (-cut funcall <> 5) '(1+ 1- (lambda (x) (/ 1.0 x)))) => '(6 4 0.2)
+ (-map (-cut <> 1 2 3) (list 'list 'vector 'string)) => '((1 2 3) [1 2 3]
"")
(-filter (-cut < <> 5) '(1 3 5 7 9)) => '(1 3))
(defexamples -not
- [elpa] externals/dash 4b805e1 041/316: Update README, (continued)
- [elpa] externals/dash 4b805e1 041/316: Update README, ELPA Syncer, 2021/02/15
- [elpa] externals/dash bcc74b5 045/316: [#200] Define setters for -first-item and -last-item, ELPA Syncer, 2021/02/15
- [elpa] externals/dash a9f90d7 016/316: Add -select-column(s), ELPA Syncer, 2021/02/15
- [elpa] externals/dash 27b1ea5 030/316: Update changelog for 2.12.x., ELPA Syncer, 2021/02/15
- [elpa] externals/dash 52e7eb4 031/316: Merge pull request #191 from Wilfred/update_changelog, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 3075aea 040/316: Add -unzip, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 2996a0d 035/316: Add a LICENSE file (#194), ELPA Syncer, 2021/02/15
- [elpa] externals/dash 9dfb01a 050/316: Correct use of eval-after-load, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 75cde71 052/316: Ensure that -first-item is as fast as car, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 05dc0aa 062/316: Add copyright assignment statement to documentation, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 4de2189 027/316: [Feature #185] -cut <> in first slot is a function,
ELPA Syncer <=
- [elpa] externals/dash b45b38a 039/316: Fix typo, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 07c61f5 046/316: [#200] Add tests for generalized variables, ELPA Syncer, 2021/02/15
- [elpa] externals/dash ff323e0 049/316: Fix setf on emacs23 (#205), ELPA Syncer, 2021/02/15
- [elpa] externals/dash 958e3fb 051/316: Merge pull request #206 from Silex/master, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 98e819e 053/316: Merge pull request #210 from Wilfred/car_opcode_with_first_item, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 6a57833 054/316: Add -iota (#207), ELPA Syncer, 2021/02/15
- [elpa] externals/dash 1e14307 061/316: Merge pull request #221 from zck/it-anywhere-in-->, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 0468a31 063/316: Merge pull request #223 from phillord/feature/doc-copyright, ELPA Syncer, 2021/02/15
- [elpa] externals/dash f69a9df 071/316: Replace -first with -some in -any?, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 1422b70 042/316: Update info, ELPA Syncer, 2021/02/15