[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash c229ba8 011/426: Rewrite to anaphoric filter funct
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash c229ba8 011/426: Rewrite to anaphoric filter function. |
Date: |
Tue, 04 Aug 2015 19:36:22 +0000 |
branch: externals/dash
commit c229ba8b12a45b9cd6b0fffd95641db7887f2b4e
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>
Rewrite to anaphoric filter function.
---
bang.el | 21 +++++++++------------
1 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/bang.el b/bang.el
index 1436a9c..e552988 100644
--- a/bang.el
+++ b/bang.el
@@ -46,35 +46,32 @@ It should only be set using dynamic scope with a let, like:
(defun !mapcat (fn list)
(!concat (!map fn list)))
-(defmacro !--iterate-with-result (&rest forms)
- `(let (result)
+(defmacro !-filter (list &rest forms)
+ `(let (!--result)
(while list
- (let ((it (car list))) ,@forms)
+ (let ((it (car list)))
+ (when (progn ,@forms)
+ (setq !--result (cons it !--result))))
(setq list (cdr list)))
- (nreverse result)))
+ (nreverse !--result)))
(defun !uniq (list)
"Return a new list with all duplicates removed.
The test for equality is done with `equal',
or with `!compare-fn' if that's non-nil."
- (!--iterate-with-result
- (add-to-list 'result it nil !compare-fn)))
+ (!-filter list (not (!contains-p !--result it))))
(defun !intersection (list list2)
"Return a new list containing only the elements that are members of both
LIST and LIST2.
The test for equality is done with `equal',
or with `!compare-fn' if that's non-nil."
- (!--iterate-with-result
- (when (!contains-p list2 it)
- (setq result (cons it result)))))
+ (!-filter list (!contains-p list2 it)))
(defun !difference (list list2)
"Return a new list with only the members of LIST that are not in LIST2.
The test for equality is done with `equal',
or with `!compare-fn' if that's non-nil."
- (!--iterate-with-result
- (unless (!contains-p list2 it)
- (setq result (cons it result)))))
+ (!-filter list (not (!contains-p list2 it))))
(defun !contains-p (list element)
"Return whether LIST contains ELEMENT.
- [elpa] externals/dash e720428 010/426: Extract basic iteration form into macro., (continued)
- [elpa] externals/dash e720428 010/426: Extract basic iteration form into macro., Phillip Lord, 2015/08/04
- [elpa] externals/dash 14673a6 007/426: Use nreverse for performance reasons., Phillip Lord, 2015/08/04
- [elpa] externals/dash 065f76b 005/426: Use ert.el to run on Emacs 23 as well., Phillip Lord, 2015/08/04
- [elpa] externals/dash 3e0ef58 012/426: !filter can now take either a function or form (anaphoric), Phillip Lord, 2015/08/04
- [elpa] externals/dash d870282 013/426: Add some tests, and fix the bugs they uncovered., Phillip Lord, 2015/08/04
- [elpa] externals/dash b24d056 014/426: !map macro, Phillip Lord, 2015/08/04
- [elpa] externals/dash f9471e4 016/426: !concat done - one less 'cl dependency, Phillip Lord, 2015/08/04
- [elpa] externals/dash 302c8ea 001/426: Initial commit., Phillip Lord, 2015/08/04
- [elpa] externals/dash 07de30e 019/426: !mapcat macro, and with that: goodbye 'cl!, Phillip Lord, 2015/08/04
- [elpa] externals/dash 4201ecd 017/426: Out with remove-if, in with !reject, Phillip Lord, 2015/08/04
- [elpa] externals/dash c229ba8 011/426: Rewrite to anaphoric filter function.,
Phillip Lord <=
- [elpa] externals/dash 73204ca 022/426: Change !contains-p to !contains? to match clojure api., Phillip Lord, 2015/08/04
- [elpa] externals/dash ad44aee 009/426: Add more tests., Phillip Lord, 2015/08/04
- [elpa] externals/dash f5b16e3 018/426: Make !partial have the same quote-less API as the rest of bang., Phillip Lord, 2015/08/04
- [elpa] externals/dash a02b6c1 021/426: Add note about no 'cl required., Phillip Lord, 2015/08/04
- [elpa] externals/dash 754dd0d 024/426: Create stand-alone anaphoric macros, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9e74cc0 027/426: Remove dead code., Phillip Lord, 2015/08/04
- [elpa] externals/dash 8eab3d1 028/426: Slight improvements to map., Phillip Lord, 2015/08/04
- [elpa] externals/dash 1997e52 031/426: Treat dashes in docstring better., Phillip Lord, 2015/08/04
- [elpa] externals/dash 52815c5 020/426: Add documentation, Phillip Lord, 2015/08/04
- [elpa] externals/dash d2dfb11 023/426: Use double-bang for anaphoric functions, Phillip Lord, 2015/08/04