[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 2b89641 049/426: Remove needless duplication.
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash 2b89641 049/426: Remove needless duplication. |
Date: |
Tue, 04 Aug 2015 19:36:38 +0000 |
branch: externals/dash
commit 2b89641b0e6b2b20c4e0f018a39b1f55c24dd960
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>
Remove needless duplication.
---
bang.el | 65 +++++++++++++++++++++++++++-----------------------------------
1 files changed, 28 insertions(+), 37 deletions(-)
diff --git a/bang.el b/bang.el
index 7c1478a..3022d28 100644
--- a/bang.el
+++ b/bang.el
@@ -33,20 +33,6 @@
"Anaphoric form of `!map'."
`(mapcar (lambda (it) ,form) ,list))
-(defun !reduce-from (fn initial-value list)
- "Returns the result of applying FN to INITIAL-VALUE and the
-first item in LIST, then applying FN to that result and the 2nd
-item, etc. If LIST contains no items, returns INITIAL-VALUE and
-FN is not called.
-
-In the anaphoric form `!!reduce-from', the accumulated value is
-exposed as `acc`."
- (let ((acc initial-value))
- (while list
- (setq acc (funcall fn acc (car list)))
- (setq list (cdr list)))
- acc))
-
(defmacro !!reduce-from (form initial-value list)
"Anaphoric form of `!reduce-from'."
`(let ((!--list ,list)
@@ -58,6 +44,22 @@ exposed as `acc`."
(setq !--list (cdr !--list)))
!--acc))
+(defun !reduce-from (fn initial-value list)
+ "Returns the result of applying FN to INITIAL-VALUE and the
+first item in LIST, then applying FN to that result and the 2nd
+item, etc. If LIST contains no items, returns INITIAL-VALUE and
+FN is not called.
+
+In the anaphoric form `!!reduce-from', the accumulated value is
+exposed as `acc`."
+ (!!reduce-from (funcall fn acc it) initial-value list))
+
+(defmacro !!reduce (form list)
+ "Anaphoric form of `!reduce'."
+ (if (eval list)
+ `(!!reduce-from ,form ,(car (eval list)) ',(cdr (eval list)))
+ `(let (acc it) ,form)))
+
(defun !reduce (fn list)
"Returns the result of applying FN to the first 2 items in LIST,
then applying FN to that result and the 3rd item, etc. If LIST
@@ -71,21 +73,6 @@ exposed as `acc`."
(!reduce-from fn (car list) (cdr list))
(funcall fn)))
-(defmacro !!reduce (form list)
- "Anaphoric form of `!reduce'."
- (if (eval list)
- `(!!reduce-from ,form ,(car (eval list)) ',(cdr (eval list)))
- `(let (acc it) ,form)))
-
-(defun !filter (fn list)
- "Returns a new list of the items in LIST for which FN returns a non-nil
value."
- (let ((result '()))
- (while list
- (when (funcall fn (car list))
- (setq result (cons (car list) result)))
- (setq list (cdr list)))
- (nreverse result)))
-
(defmacro !!filter (form list)
"Anaphoric form of `!filter'."
`(let ((!--list ,list)
@@ -97,28 +84,32 @@ exposed as `acc`."
(setq !--list (cdr !--list)))
(nreverse !--result)))
-(defun !remove (fn list)
- "Returns a new list of the items in LIST for which FN returns nil."
- (!!filter (not (funcall fn it)) list))
+(defun !filter (fn list)
+ "Returns a new list of the items in LIST for which FN returns a non-nil
value."
+ (!!filter (funcall fn it) list))
(defmacro !!remove (form list)
"Anaphoric form of `!remove'."
`(!!filter (not ,form) ,list))
+(defun !remove (fn list)
+ "Returns a new list of the items in LIST for which FN returns nil."
+ (!!remove (funcall fn it) list))
+
(defun !concat (&rest lists)
"Returns a new list with the concatenation of the elements in
the supplied LISTS."
(apply 'append (append lists '(nil))))
-(defun !mapcat (fn list)
- "Returns the result of applying concat to the result of applying map to FN
and LIST.
-Thus function FN should return a collection."
- (apply '!concat (!map fn list)))
-
(defmacro !!mapcat (form list)
"Anaphoric form of `!mapcat'."
`(apply '!concat (!!map ,form ,list)))
+(defun !mapcat (fn list)
+ "Returns the result of applying concat to the result of applying map to FN
and LIST.
+Thus function FN should return a collection."
+ (!!mapcat (funcall fn it) list))
+
(defun !partial (fn &rest args)
"Takes a function FN and fewer than the normal arguments to FN,
and returns a fn that takes a variable number of additional ARGS.
- [elpa] externals/dash 78fc2a3 038/426: Quote and downcase params with digits in them too., (continued)
- [elpa] externals/dash 78fc2a3 038/426: Quote and downcase params with digits in them too., Phillip Lord, 2015/08/04
- [elpa] externals/dash 32053cd 042/426: Update readme with development notes., Phillip Lord, 2015/08/04
- [elpa] externals/dash 0912aa2 048/426: Rename !uniq to !distinct, Phillip Lord, 2015/08/04
- [elpa] externals/dash 24262a1 054/426: Add file-local font-lock for defexamples and =>, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9312469 053/426: !keep, Phillip Lord, 2015/08/04
- [elpa] externals/dash 657ee8b 040/426: Slight improvements to docs., Phillip Lord, 2015/08/04
- [elpa] externals/dash 286d1d8 050/426: Show quotes around strings in examples., Phillip Lord, 2015/08/04
- [elpa] externals/dash db8a745 056/426: Add !each, Phillip Lord, 2015/08/04
- [elpa] externals/dash f59b480 055/426: Add !some and !every?, Phillip Lord, 2015/08/04
- [elpa] externals/dash b337ef9 052/426: Sync examples-to-docs.el with the one in s.el, Phillip Lord, 2015/08/04
- [elpa] externals/dash 2b89641 049/426: Remove needless duplication.,
Phillip Lord <=
- [elpa] externals/dash d83ea8a 061/426: Add installation instructions., Phillip Lord, 2015/08/04
- [elpa] externals/dash e1a362c 047/426: Update README to reflect changes in readme generation., Phillip Lord, 2015/08/04
- [elpa] externals/dash 5bd4593 067/426: Add note about !rpartial only working on Emacs 24+, Phillip Lord, 2015/08/04
- [elpa] externals/dash 05dec7a 062/426: Fix example., Phillip Lord, 2015/08/04
- [elpa] externals/dash 6f17346 068/426: Don't run !rpartial tests on Emacsen <24, Phillip Lord, 2015/08/04
- [elpa] externals/dash 4205e58 064/426: Add clojure threading macros, !-> and !->>, Phillip Lord, 2015/08/04
- [elpa] externals/dash cd2a793 069/426: Run travis-ci on both E23 and E24, Phillip Lord, 2015/08/04
- [elpa] externals/dash 1a7ad85 065/426: Mention Melpa in README, Phillip Lord, 2015/08/04
- [elpa] externals/dash 6be4c03 058/426: !first, Phillip Lord, 2015/08/04
- [elpa] externals/dash 0991c29 057/426: Added some common aliases, Phillip Lord, 2015/08/04