[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash e6cae0b 279/426: Merge pull request #68 from rejee
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash e6cae0b 279/426: Merge pull request #68 from rejeep/list-function |
Date: |
Tue, 04 Aug 2015 19:38:16 +0000 |
branch: externals/dash
commit e6cae0bee7486571ce2e66e1ef8fd27c8713c10d
Merge: 6abc35a 930b390
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>
Merge pull request #68 from rejeep/list-function
Add -list function.
---
README.md | 13 +++++++++++++
dash.el | 9 +++++++++
dev/examples.el | 8 +++++++-
3 files changed, 29 insertions(+), 1 deletions(-)
diff --git a/README.md b/README.md
index 3e6701b..4ee7cde 100644
--- a/README.md
+++ b/README.md
@@ -125,6 +125,7 @@ Include this in your emacs settings to get syntax
highlighting:
* [-first-item](#-first-item-list) `(list)`
* [-last-item](#-last-item-list) `(list)`
* [-sort](#-sort-comparator-list) `(comparator list)`
+* [-list](#-list-rest-args) `(&rest args)`
### Tree operations
@@ -1023,6 +1024,18 @@ if the first element should sort before the second.
(--sort (< it other) '(3 1 2)) ;; => '(1 2 3)
```
+#### -list `(&rest args)`
+
+Return a list with `args`.
+
+If first item of `args` is already a list, simply return `args`. If
+not, return a list with `args` as elements.
+
+```cl
+(-list 1) ;; => '(1)
+(-list 1 2 3) ;; => '(1 2 3)
+```
+
## Tree operations
diff --git a/dash.el b/dash.el
index 12c04bc..e6013ce 100644
--- a/dash.el
+++ b/dash.el
@@ -994,6 +994,14 @@ if the first element should sort before the second."
(declare (debug t))
`(-sort (lambda (it other) ,form) ,list))
+(defun -list (&rest args)
+ "Return a list with ARGS.
+
+If first item of ARGS is already a list, simply return ARGS. If
+not, return a list with ARGS as elements."
+ (let ((arg (car args)))
+ (if (listp arg) arg args)))
+
(defun -repeat (n x)
"Return a list with X repeated N times.
Returns nil if N is less than 1."
@@ -1306,6 +1314,7 @@ structure such as plist or alist."
"-same-items-p"
"-sort"
"--sort"
+ "-list"
"-repeat"
"-sum"
"-product"
diff --git a/dev/examples.el b/dev/examples.el
index f1b85bb..88e4f3d 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -403,7 +403,13 @@
(-sort '< '(3 1 2)) => '(1 2 3)
(-sort '> '(3 1 2)) => '(3 2 1)
(--sort (< it other) '(3 1 2)) => '(1 2 3)
- (let ((l '(3 1 2))) (-sort '> l) l) => '(3 1 2)))
+ (let ((l '(3 1 2))) (-sort '> l) l) => '(3 1 2))
+
+ (defexamples -list
+ (-list 1) => '(1)
+ (-list 1 2 3) => '(1 2 3)
+ (-list '(1 2 3) => '(1 2 3))
+ (-list '((1) (2)) => '((1) (2)))))
(def-example-group "Tree operations" nil
(defexamples -tree-map
- [elpa] externals/dash e7bc8fe 250/426: Make dash-specific font lock optional, (continued)
- [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, 2015/08/04
- [elpa] externals/dash e6cae0b 279/426: Merge pull request #68 from rejeep/list-function,
Phillip Lord <=
- [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
- [elpa] externals/dash 2ecc073 316/426: Reorder the partition examples to follow more logical order, add tests, Phillip Lord, 2015/08/04