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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/dash 8052eb9 253/426: Merge pull request #55 from Fuco1


From: Phillip Lord
Subject: [elpa] externals/dash 8052eb9 253/426: Merge pull request #55 from Fuco1/snoc
Date: Tue, 04 Aug 2015 19:38:06 +0000

branch: externals/dash
commit 8052eb9b7d46700c7ab72cf6b6510a91f9e61f5b
Merge: 2ee84cb f4ba8db
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>

    Merge pull request #55 from Fuco1/snoc
    
    Add -snoc
---
 README.md       |   15 +++++++++++++++
 dash.el         |    9 +++++++++
 dev/examples.el |    5 +++++
 3 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md
index 5d0357e..d22b9e1 100644
--- a/README.md
+++ b/README.md
@@ -129,6 +129,7 @@ Include this in your emacs settings to get syntax 
highlighting:
 
 * [-repeat](#-repeat-n-x) `(n x)`
 * [-cons*](#-cons-rest-args) `(&rest args)`
+* [-snoc](#-snoc-list-elem-rest-elements) `(list elem &rest elements)`
 * [-interpose](#-interpose-sep-list) `(sep list)`
 * [-interleave](#-interleave-rest-lists) `(&rest lists)`
 * [-zip-with](#-zip-with-fn-list1-list2) `(fn list1 list2)`
@@ -866,6 +867,20 @@ a dotted list.
 (-cons* 1) ;; => 1
 ```
 
+#### -snoc `(list elem &rest elements)`
+
+Append `elem` to the end of the list.
+
+This is like `cons`, but operates on the end of list.
+
+If `elements` is non nil, append these to the list as well.
+
+```cl
+(-snoc '(1 2 3) 4) ;; => '(1 2 3 4)
+(-snoc '(1 2 3) 4 5 6) ;; => '(1 2 3 4 5 6)
+(-snoc '(1 2 3) '(4 5 6)) ;; => '(1 2 3 (4 5 6))
+```
+
 #### -interpose `(sep list)`
 
 Returns a new list of all elements in `list` separated by `sep`.
diff --git a/dash.el b/dash.el
index 0245bfe..5bb4323 100644
--- a/dash.el
+++ b/dash.el
@@ -275,6 +275,14 @@ a dotted list."
         (setq res (cons res it)))))
     res))
 
+(defun -snoc (list elem &rest elements)
+  "Append ELEM to the end of the list.
+
+This is like `cons', but operates on the end of list.
+
+If ELEMENTS is non nil, append these to the list as well."
+  (-concat list (list elem) elements))
+
 (defmacro --first (form list)
   "Anaphoric form of `-first'."
   (let ((n (make-symbol "needle")))
@@ -1225,6 +1233,7 @@ structure such as plist or alist."
                              "-contains-p"
                              "-repeat"
                              "-cons*"
+                             "-snoc"
                              "-sum"
                              "-product"
                              "-min"
diff --git a/dev/examples.el b/dev/examples.el
index 64b0c9a..c31f4bf 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -304,6 +304,11 @@
     (-cons* 1 2 3) => '(1 2 . 3)
     (-cons* 1) => 1)
 
+  (defexamples -snoc
+    (-snoc '(1 2 3) 4) => '(1 2 3 4)
+    (-snoc '(1 2 3) 4 5 6) => '(1 2 3 4 5 6)
+    (-snoc '(1 2 3) '(4 5 6)) => '(1 2 3 (4 5 6)))
+
   (defexamples -interpose
     (-interpose "-" '()) => '()
     (-interpose "-" '("a")) => '("a")



reply via email to

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