emacs-elpa-diffs
[Top][All Lists]
Advanced

[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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]