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

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

[elpa] externals/dash 6fc652d 331/426: Merge pull request #95 from Wilfr


From: Phillip Lord
Subject: [elpa] externals/dash 6fc652d 331/426: Merge pull request #95 from Wilfred/shallow-copy-function
Date: Tue, 04 Aug 2015 19:38:40 +0000

branch: externals/dash
commit 6fc652de8c88e7bce1e2d8feeccb2ef9abfdbc68
Merge: d9879e9 25c114c
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>

    Merge pull request #95 from Wilfred/shallow-copy-function
    
    Implementing a shallow copy counterpart to -clone.
---
 README.md       |   10 ++++++++++
 dash.el         |    4 ++++
 dev/examples.el |    8 ++++++--
 3 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 435879e..8eb8e26 100644
--- a/README.md
+++ b/README.md
@@ -50,6 +50,7 @@ new list.
 * [-splice](#-splice-pred-fun-list) `(pred fun list)`
 * [-splice-list](#-splice-list-pred-new-list-list) `(pred new-list list)`
 * [-mapcat](#-mapcat-fn-list) `(fn list)`
+* [-copy](#-copy-list) `(list)`
 
 ### Sublist selection
 
@@ -369,6 +370,15 @@ Thus function `fn` should return a list.
 (--mapcat (list 0 it) '(1 2 3)) ;; => '(0 1 0 2 0 3)
 ```
 
+#### -copy `(list)`
+
+Create a shallow copy of `list`.
+
+```cl
+(-copy '(1 2 3)) ;; => '(1 2 3)
+(let ((a '(1 2 3))) (eq a (-copy a))) ;; => nil
+```
+
 
 ## Sublist selection
 
diff --git a/dash.el b/dash.el
index c8a1253..e83324d 100644
--- a/dash.el
+++ b/dash.el
@@ -311,6 +311,9 @@ See also: `-flatten'"
 Thus function FN should return a list."
   (--mapcat (funcall fn it) list))
 
+(defalias '-copy 'copy-sequence
+  "Create a shallow copy of LIST.")
+
 (defun -splice (pred fun list)
   "Splice lists generated by FUN in place of elements matching PRED in LIST.
 
@@ -1559,6 +1562,7 @@ structure such as plist or alist."
                              "-concat"
                              "-mapcat"
                              "--mapcat"
+                             "-copy"
                              "-cons*"
                              "-snoc"
                              "-first"
diff --git a/dev/examples.el b/dev/examples.el
index 26ed0e4..d42b05c 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -48,7 +48,11 @@ new list."
   (defexamples -mapcat
     (-mapcat 'list '(1 2 3)) => '(1 2 3)
     (-mapcat (lambda (item) (list 0 item)) '(1 2 3)) => '(0 1 0 2 0 3)
-    (--mapcat (list 0 it) '(1 2 3)) => '(0 1 0 2 0 3)))
+    (--mapcat (list 0 it) '(1 2 3)) => '(0 1 0 2 0 3))
+
+  (defexamples -copy
+    (-copy '(1 2 3)) => '(1 2 3)
+    (let ((a '(1 2 3))) (eq a (-copy a))) => nil))
 
 (def-example-group "Sublist selection"
   "Functions returning a sublist of the original list."
@@ -620,7 +624,7 @@ new list."
                  "}"
                  '((elips-mode (foo (bar . booze)) (baz . qux)) (c-mode (foo . 
bla) (bum . bam)))))
     => "{elips-mode : {foo : {bar -> booze}, baz -> qux}, c-mode : {foo -> 
bla, bum -> bam}}")
-
+  
   (defexamples -clone
     (let* ((a '(1 2 3)) (b (-clone a))) (nreverse a) b) => '(1 2 3)))
 



reply via email to

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