[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash adaeff7 274/426: Merge pull request #65 from rejee
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash adaeff7 274/426: Merge pull request #65 from rejeep/same-items-predicate |
Date: |
Tue, 04 Aug 2015 19:38:14 +0000 |
branch: externals/dash
commit adaeff7b3879cc66930f8d7445c6dce4c836b733
Merge: 4818368 386ec0a
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>
Merge pull request #65 from rejeep/same-items-predicate
Add -same-items? function.
---
README.md | 13 +++++++++++++
dash.el | 14 ++++++++++++++
dev/examples.el | 9 ++++++++-
3 files changed, 35 insertions(+), 1 deletions(-)
diff --git a/README.md b/README.md
index 83ca63e..fd3c632 100644
--- a/README.md
+++ b/README.md
@@ -79,6 +79,7 @@ Include this in your emacs settings to get syntax
highlighting:
* [-none?](#-none-pred-list) `(pred list)`
* [-only-some?](#-only-some-pred-list) `(pred list)`
* [-contains?](#-contains-list-element) `(list element)`
+* [-same-items?](#-same-items-list-list2) `(list list2)`
### Partitioning
@@ -620,6 +621,18 @@ or with `-compare-fn` if that's non-nil.
(-contains? '(1 2 3) 4) ;; => nil
```
+#### -same-items? `(list list2)`
+
+Return true if `list` and `list2` has the same items.
+
+The order of the elements in the lists does not matter.
+
+```cl
+(-same-items? '(1 2 3) '(1 2 3)) ;; => t
+(-same-items? '(1 2 3) '(3 2 1)) ;; => t
+(-same-items? '(1 2 3) '(1 2 3 4)) ;; => nil
+```
+
## Partitioning
diff --git a/dash.el b/dash.el
index b999df5..ae73bf3 100644
--- a/dash.el
+++ b/dash.el
@@ -964,6 +964,18 @@ or with `-compare-fn' if that's non-nil."
(defalias '-contains-p '-contains?)
+(defun -same-items? (list list2)
+ "Return true if LIST and LIST2 has the same items.
+
+The order of the elements in the lists does not matter."
+ (let ((length-a (length list))
+ (length-b (length list2)))
+ (and
+ (= length-a length-b)
+ (= length-a (length (-intersection list list2))))))
+
+(defalias '-same-items-p '-same-items?)
+
(defun -sort (comparator list)
"Sort LIST, stably, comparing elements using COMPARATOR.
Returns the sorted list. LIST is NOT modified by side effects.
@@ -1284,6 +1296,8 @@ structure such as plist or alist."
"-difference"
"-contains?"
"-contains-p"
+ "-same-items?"
+ "-same-items-p"
"-sort"
"--sort"
"-repeat"
diff --git a/dev/examples.el b/dev/examples.el
index 792883a..f1b85bb 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -226,7 +226,14 @@
(-contains? '(1 2 3) 2) => t
(-contains? '(1 2 3) 4) => nil
(-contains? '() 1) => nil
- (-contains? '() '()) => nil))
+ (-contains? '() '()) => nil)
+
+ (defexamples -same-items?
+ (-same-items? '(1 2 3) '(1 2 3)) => t
+ (-same-items? '(1 2 3) '(3 2 1)) => t
+ (-same-items? '(1 2 3) '(1 2 3 4)) => nil
+ (-same-items? '((a . 1) (b . 2)) '((a . 1) (b . 2))) => t
+ (-same-items? '(1 2 3) '(2 3 1)) => t))
(def-example-group "Partitioning" nil
(defexamples -split-at
- [elpa] externals/dash 386ec0a 273/426: Add -same-items? function., (continued)
- [elpa] externals/dash 386ec0a 273/426: Add -same-items? function., Phillip Lord, 2015/08/04
- [elpa] externals/dash e7bc8fe 250/426: Make dash-specific font lock optional, Phillip Lord, 2015/08/04
- [elpa] externals/dash a84a434 267/426: 2.4.1 in readme-template too, Phillip Lord, 2015/08/04
- [elpa] externals/dash 4818368 272/426: Release 2.4.3, Phillip Lord, 2015/08/04
- [elpa] externals/dash b661f96 269/426: Merge pull request #62 from Fuco1/consfix, Phillip Lord, 2015/08/04
- [elpa] externals/dash 25be31a 270/426: Release 2.4.2, Phillip Lord, 2015/08/04
- [elpa] externals/dash f86d235 268/426: Fix -cons*, Phillip Lord, 2015/08/04
- [elpa] externals/dash 3eb91fe 280/426: Add `-find-last-index`, Phillip Lord, 2015/08/04
- [elpa] externals/dash ec9afcb 255/426: Merge pull request #54 from Fuco1/index/modify, Phillip Lord, 2015/08/04
- [elpa] externals/dash 930b390 278/426: Add -list function., Phillip Lord, 2015/08/04
- [elpa] externals/dash adaeff7 274/426: Merge pull request #65 from rejeep/same-items-predicate,
Phillip Lord <=
- [elpa] externals/dash e6cae0b 279/426: Merge pull request #68 from rejeep/list-function, Phillip Lord, 2015/08/04
- [elpa] externals/dash f18a520 326/426: Release 2.7.0, Phillip Lord, 2015/08/04
- [elpa] externals/dash 7eb8307 283/426: Merge pull request #71 from Fuco1/find-last-index, Phillip Lord, 2015/08/04
- [elpa] externals/dash 7f0fadc 317/426: Add -prodfn, Phillip Lord, 2015/08/04
- [elpa] externals/dash 960b05f 276/426: Set -each, -each-while and -dotimes indent levels to 1., Phillip Lord, 2015/08/04
- [elpa] externals/dash d948086 315/426: Add -iteratefn, Phillip Lord, 2015/08/04
- [elpa] externals/dash a09a4b2 318/426: Add code markup for docstrings and fix erroneous whitespace in docstring, Phillip Lord, 2015/08/04
- [elpa] externals/dash 38307e3 223/426: Partition docs, Phillip Lord, 2015/08/04
- [elpa] externals/dash f3b0a55 321/426: Change -predicate-p examples to -predicate? to maintain consistency, Phillip Lord, 2015/08/04
- [elpa] externals/dash 7e4adb5 319/426: Add missing keywords to highlight list, Phillip Lord, 2015/08/04