[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 9a3dfdd 113/426: Name parameter PRED when function
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash 9a3dfdd 113/426: Name parameter PRED when function expects predicate. |
Date: |
Tue, 04 Aug 2015 19:37:04 +0000 |
branch: externals/dash
commit 9a3dfdd581ce76110a9cf2c9012ac8ee7bf92a07
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>
Name parameter PRED when function expects predicate.
---
README.md | 66 ++++++++++++++++++++++++++++++++++++-------------------------
dash.el | 58 ++++++++++++++++++++++++++++-------------------------
2 files changed, 70 insertions(+), 54 deletions(-)
diff --git a/README.md b/README.md
index 5632606..0e6dc28 100644
--- a/README.md
+++ b/README.md
@@ -15,30 +15,31 @@ Or you can just dump `dash.el` in your load path somewhere.
* [-map](#-map-fn-list) `(fn list)`
* [-reduce-from](#-reduce-from-fn-initial-value-list) `(fn initial-value list)`
* [-reduce](#-reduce-fn-list) `(fn list)`
-* [-filter](#-filter-fn-list) `(fn list)`
-* [-remove](#-remove-fn-list) `(fn list)`
+* [-filter](#-filter-pred-list) `(pred list)`
+* [-remove](#-remove-pred-list) `(pred list)`
* [-keep](#-keep-fn-list) `(fn list)`
* [-flatten](#-flatten-l) `(l)`
* [-concat](#-concat-rest-lists) `(&rest lists)`
* [-mapcat](#-mapcat-fn-list) `(fn list)`
-* [-any?](#-any-fn-list) `(fn list)`
-* [-all?](#-all-fn-list) `(fn list)`
-* [-none?](#-none-fn-list) `(fn list)`
+* [-any?](#-any-pred-list) `(pred list)`
+* [-all?](#-all-pred-list) `(pred list)`
+* [-none?](#-none-pred-list) `(pred list)`
+* [-only-some?](#-only-some-pred-list) `(pred list)`
* [-each](#-each-list-fn) `(list fn)`
* [-each-while](#-each-while-list-pred-fn) `(list pred fn)`
* [-dotimes](#-dotimes-num-fn) `(num fn)`
* [-take](#-take-n-list) `(n list)`
* [-drop](#-drop-n-list) `(n list)`
-* [-take-while](#-take-while-fn-list) `(fn list)`
-* [-drop-while](#-drop-while-fn-list) `(fn list)`
+* [-take-while](#-take-while-pred-list) `(pred list)`
+* [-drop-while](#-drop-while-pred-list) `(pred list)`
* [-split-at](#-split-at-n-list) `(n list)`
-* [-split-with](#-split-with-fn-list) `(fn list)`
+* [-split-with](#-split-with-pred-list) `(pred list)`
* [-partition](#-partition-n-list) `(n list)`
* [-partition-all](#-partition-all-n-list) `(n list)`
* [-interpose](#-interpose-sep-list) `(sep list)`
* [-interleave](#-interleave-rest-lists) `(&rest lists)`
* [-replace-where](#-replace-where-pred-rep-list) `(pred rep list)`
-* [-first](#-first-fn-list) `(fn list)`
+* [-first](#-first-pred-list) `(pred list)`
* [-difference](#-difference-list-list) `(list list2)`
* [-intersection](#-intersection-list-list) `(list list2)`
* [-distinct](#-distinct-list) `(list)`
@@ -121,9 +122,9 @@ exposed as `acc`.
(--reduce (format "%s-%s" acc it) '(1 2 3)) ;; => "1-2-3"
```
-### -filter `(fn list)`
+### -filter `(pred list)`
-Returns a new list of the items in `list` for which `fn` returns a non-nil
value.
+Returns a new list of the items in `list` for which `pred` returns a non-nil
value.
Alias: `-select`
@@ -133,9 +134,9 @@ Alias: `-select`
(--filter (= 0 (% it 2)) '(1 2 3 4)) ;; => '(2 4)
```
-### -remove `(fn list)`
+### -remove `(pred list)`
-Returns a new list of the items in `list` for which `fn` returns nil.
+Returns a new list of the items in `list` for which `pred` returns nil.
Alias: `-reject`
@@ -185,9 +186,9 @@ Thus function `fn` should return a collection.
(--mapcat (list 0 it) '(1 2 3)) ;; => '(0 1 0 2 0 3)
```
-### -any? `(fn list)`
+### -any? `(pred list)`
-Returns t if (`fn` x) is non-nil for any x in `list`, else nil.
+Returns t if (`pred` x) is non-nil for any x in `list`, else nil.
Alias: `-some?`
@@ -197,9 +198,9 @@ Alias: `-some?`
(--any? (= 0 (% it 2)) '(1 2 3)) ;; => t
```
-### -all? `(fn list)`
+### -all? `(pred list)`
-Returns t if (`fn` x) is non-nil for all x in `list`, else nil.
+Returns t if (`pred` x) is non-nil for all x in `list`, else nil.
Alias: `-every?`
@@ -209,9 +210,9 @@ Alias: `-every?`
(--all? (= 0 (% it 2)) '(2 4 6)) ;; => t
```
-### -none? `(fn list)`
+### -none? `(pred list)`
-Returns t if (`fn` x) is nil for all x in `list`, else nil.
+Returns t if (`pred` x) is nil for all x in `list`, else nil.
```cl
(-none? 'even? '(1 2 3)) ;; => nil
@@ -219,6 +220,17 @@ Returns t if (`fn` x) is nil for all x in `list`, else nil.
(--none? (= 0 (% it 2)) '(1 2 3)) ;; => nil
```
+### -only-some? `(pred list)`
+
+Returns `t` if there is a mix of items in `list` that matches and does not
match `pred`.
+Returns `nil` both if all items match the predicate, and if none of the items
match the predicate.
+
+```cl
+(-only-some? 'even? '(1 2 3)) ;; => t
+(-only-some? 'even? '(1 3 5)) ;; => nil
+(-only-some? 'even? '(2 4 6)) ;; => nil
+```
+
### -each `(list fn)`
Calls `fn` with every item in `list`. Returns nil, used for side-effects only.
@@ -266,9 +278,9 @@ Returns the tail of `list` without the first `n` items.
(-drop 17 '(1 2 3 4 5)) ;; => '()
```
-### -take-while `(fn list)`
+### -take-while `(pred list)`
-Returns a new list of successive items from `list` while (`fn` item) returns a
non-nil value.
+Returns a new list of successive items from `list` while (`pred` item) returns
a non-nil value.
```cl
(-take-while 'even? '(1 2 3 4)) ;; => '()
@@ -276,9 +288,9 @@ Returns a new list of successive items from `list` while
(`fn` item) returns a n
(--take-while (< it 4) '(1 2 3 4 3 2 1)) ;; => '(1 2 3)
```
-### -drop-while `(fn list)`
+### -drop-while `(pred list)`
-Returns the tail of `list` starting from the first item for which (`fn` item)
returns nil.
+Returns the tail of `list` starting from the first item for which (`pred`
item) returns nil.
```cl
(-drop-while 'even? '(1 2 3 4)) ;; => '(1 2 3 4)
@@ -295,9 +307,9 @@ Returns a list of ((-take `n` `list`) (-drop `n` `list`))
(-split-at 17 '(1 2 3 4 5)) ;; => '((1 2 3 4 5) nil)
```
-### -split-with `(fn list)`
+### -split-with `(pred list)`
-Returns a list of ((-take-while `fn` `list`) (-drop-while `fn` `list`))
+Returns a list of ((-take-while `pred` `list`) (-drop-while `pred` `list`))
```cl
(-split-with 'even? '(1 2 3 4)) ;; => '(nil (1 2 3 4))
@@ -360,9 +372,9 @@ through the `rep` function.
(--replace-where (= it 2) 17 '(1 2 3 4)) ;; => '(1 17 3 4)
```
-### -first `(fn list)`
+### -first `(pred list)`
-Returns the first x in `list` where (`fn` x) is non-nil, else nil.
+Returns the first x in `list` where (`pred` x) is non-nil, else nil.
To get the first item in the list no questions asked, use `car`.
diff --git a/dash.el b/dash.el
index 8159bb7..55074c7 100644
--- a/dash.el
+++ b/dash.el
@@ -131,11 +131,11 @@ exposed as `acc`."
(--each ,list (when ,form (!cons it ,r)))
(nreverse ,r))))
-(defun -filter (fn list)
- "Returns a new list of the items in LIST for which FN returns a non-nil
value.
+(defun -filter (pred list)
+ "Returns a new list of the items in LIST for which PRED returns a non-nil
value.
Alias: `-select'"
- (--filter (funcall fn it) list))
+ (--filter (funcall pred it) list))
(defalias '-select '-filter)
(defalias '--select '--filter)
@@ -144,11 +144,11 @@ Alias: `-select'"
"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.
+(defun -remove (pred list)
+ "Returns a new list of the items in LIST for which PRED returns nil.
Alias: `-reject'"
- (--remove (funcall fn it) list))
+ (--remove (funcall pred it) list))
(defalias '-reject '-remove)
(defalias '--reject '--remove)
@@ -192,11 +192,11 @@ Thus function FN should return a collection."
(when ,form (setq ,n it)))
,n)))
-(defun -first (fn list)
- "Returns the first x in LIST where (FN x) is non-nil, else nil.
+(defun -first (pred list)
+ "Returns the first x in LIST where (PRED x) is non-nil, else nil.
To get the first item in the list no questions asked, use `car'."
- (--first (funcall fn it) list))
+ (--first (funcall pred it) list))
(defun ---truthy? (val)
(not (null val)))
@@ -205,11 +205,11 @@ To get the first item in the list no questions asked, use
`car'."
"Anaphoric form of `-any?'."
`(---truthy? (--first ,form ,list)))
-(defun -any? (fn list)
- "Returns t if (FN x) is non-nil for any x in LIST, else nil.
+(defun -any? (pred list)
+ "Returns t if (PRED x) is non-nil for any x in LIST, else nil.
Alias: `-some?'"
- (--any? (funcall fn it) list))
+ (--any? (funcall pred it) list))
(defalias '-some? '-any?)
(defalias '--some? '--any?)
@@ -226,11 +226,11 @@ Alias: `-some?'"
(--each-while ,list ,a (setq ,a ,form))
(---truthy? ,a))))
-(defun -all? (fn list)
- "Returns t if (FN x) is non-nil for all x in LIST, else nil.
+(defun -all? (pred list)
+ "Returns t if (PRED x) is non-nil for all x in LIST, else nil.
Alias: `-every?'"
- (--all? (funcall fn it) list))
+ (--all? (funcall pred it) list))
(defalias '-every? '-all?)
(defalias '--every? '--all?)
@@ -244,9 +244,9 @@ Alias: `-every?'"
"Anaphoric form of `-none?'."
`(--all? (not ,form) ,list))
-(defun -none? (fn list)
- "Returns t if (FN x) is nil for all x in LIST, else nil."
- (--none? (funcall fn it) list))
+(defun -none? (pred list)
+ "Returns t if (PRED x) is nil for all x in LIST, else nil."
+ (--none? (funcall pred it) list))
(defalias '-none-p '-none?)
(defalias '--none-p '--none?)
@@ -289,9 +289,9 @@ Returns `nil` both if all items match the predicate, and if
none of the items ma
(--each-while ,list ,form (!cons it ,r))
(nreverse ,r))))
-(defun -take-while (fn list)
- "Returns a new list of successive items from LIST while (FN item) returns a
non-nil value."
- (--take-while (funcall fn it) list))
+(defun -take-while (pred list)
+ "Returns a new list of successive items from LIST while (PRED item) returns
a non-nil value."
+ (--take-while (funcall pred it) list))
(defmacro --drop-while (form list)
"Anaphoric form of `-drop-while'."
@@ -301,9 +301,9 @@ Returns `nil` both if all items match the predicate, and if
none of the items ma
(!cdr ,l))
,l)))
-(defun -drop-while (fn list)
- "Returns the tail of LIST starting from the first item for which (FN item)
returns nil."
- (--drop-while (funcall fn it) list))
+(defun -drop-while (pred list)
+ "Returns the tail of LIST starting from the first item for which (PRED item)
returns nil."
+ (--drop-while (funcall pred it) list))
(defun -split-at (n list)
"Returns a list of ((-take N LIST) (-drop N LIST))"
@@ -315,9 +315,9 @@ Returns `nil` both if all items match the predicate, and if
none of the items ma
`(list (--take-while ,form ,list)
(--drop-while ,form ,list)))
-(defun -split-with (fn list)
- "Returns a list of ((-take-while FN LIST) (-drop-while FN LIST))"
- (--split-with (funcall fn it) list))
+(defun -split-with (pred list)
+ "Returns a list of ((-take-while PRED LIST) (-drop-while PRED LIST))"
+ (--split-with (funcall pred it) list))
(defun -partition (n list)
"Returns a new list with the items in LIST grouped into N-sized sublists.
@@ -527,6 +527,10 @@ or with `-compare-fn' if that's non-nil."
"-none?"
"-none-p"
"--none-p"
+ "-only-some?"
+ "--only-some?"
+ "-only-some-p"
+ "--only-some-p"
"-take"
"-drop"
"--take-while"
- [elpa] externals/dash f1c8453 083/426: Rename to dash., (continued)
- [elpa] externals/dash f1c8453 083/426: Rename to dash., Phillip Lord, 2015/08/04
- [elpa] externals/dash 51ddc13 110/426: Nice indentation for threading macros., Phillip Lord, 2015/08/04
- [elpa] externals/dash ba60707 103/426: Use --each-while to simplify implementations., Phillip Lord, 2015/08/04
- [elpa] externals/dash c56925a 111/426: Add font-lock for new functions and the `it` token., Phillip Lord, 2015/08/04
- [elpa] externals/dash a081c72 114/426: Fix tests., Phillip Lord, 2015/08/04
- [elpa] externals/dash a336d78 112/426: Add -only-some?, Phillip Lord, 2015/08/04
- [elpa] externals/dash 81a3247 104/426: Let -each and -each-while take multiple forms., Phillip Lord, 2015/08/04
- [elpa] externals/dash d857f73 118/426: Merge pull request #3 from rejeep/join-alias, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9faa422 115/426: Add -partition-by, Phillip Lord, 2015/08/04
- [elpa] externals/dash f034c16 119/426: Add -union (thanks to @Fuco1), Phillip Lord, 2015/08/04
- [elpa] externals/dash 9a3dfdd 113/426: Name parameter PRED when function expects predicate.,
Phillip Lord <=
- [elpa] externals/dash cca9b1b 121/426: Also run tests on Emacs24, Phillip Lord, 2015/08/04
- [elpa] externals/dash c669282 123/426: Add @Fuco1 to list of contributors., Phillip Lord, 2015/08/04
- [elpa] externals/dash 12ed9f6 100/426: Add destructive operations !cons og !cdr, Phillip Lord, 2015/08/04
- [elpa] externals/dash c025efb 122/426: Add -separate (thanks @Fuco1), Phillip Lord, 2015/08/04
- [elpa] externals/dash 2c5b86e 117/426: Add -join as alias to -distinct., Phillip Lord, 2015/08/04
- [elpa] externals/dash 1c4e5d7 125/426: Remove eval from --reduce, it is evil., Phillip Lord, 2015/08/04
- [elpa] externals/dash 8f91ec8 126/426: 1.0.2, Phillip Lord, 2015/08/04
- [elpa] externals/dash 1120417 127/426: Add -group-by, Phillip Lord, 2015/08/04
- [elpa] externals/dash 5e72ff9 120/426: Include numbers in github ids., Phillip Lord, 2015/08/04
- [elpa] externals/dash a23aa4b 128/426: Add examples for -group-by, Phillip Lord, 2015/08/04