[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 25c114c 330/426: Implementing a shallow copy count
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash 25c114c 330/426: Implementing a shallow copy counterpart to -clone. |
Date: |
Tue, 04 Aug 2015 19:38:39 +0000 |
branch: externals/dash
commit 25c114c53ca650f978f62285aa78a3f4847a2e3c
Author: Wilfred Hughes <address@hidden>
Commit: Wilfred Hughes <address@hidden>
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)))
- [elpa] externals/dash 960b05f 276/426: Set -each, -each-while and -dotimes indent levels to 1., (continued)
- [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
- [elpa] externals/dash eea928a 320/426: Add -replace, Phillip Lord, 2015/08/04
- [elpa] externals/dash d9879e9 329/426: Release 2.8.0, Phillip Lord, 2015/08/04
- [elpa] externals/dash f8873a0 327/426: Update readme-template with changes from last release, Phillip Lord, 2015/08/04
- [elpa] externals/dash 25c114c 330/426: Implementing a shallow copy counterpart to -clone.,
Phillip Lord <=
- [elpa] externals/dash f257fb9 328/426: Add -butlast, Phillip Lord, 2015/08/04
- [elpa] externals/dash 174747e 323/426: Add -splice and -splice-list, Phillip Lord, 2015/08/04
- [elpa] externals/dash ab99be6 335/426: Add -fix, Phillip Lord, 2015/08/04
- [elpa] externals/dash b1e585d 337/426: Update copyright notice, Phillip Lord, 2015/08/04
- [elpa] externals/dash 3adad97 334/426: Add -non-nil, Phillip Lord, 2015/08/04
- [elpa] externals/dash 166bccd 333/426: Add -tree-map-nodes, Phillip Lord, 2015/08/04
- [elpa] externals/dash 05fa92f 342/426: [-let] Transpose nreverse/flatten, Phillip Lord, 2015/08/04
- [elpa] externals/dash f0831d3 339/426: Add -lambda, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9ebcce6 325/426: Add some niceties to font-locking of examples, Phillip Lord, 2015/08/04
- [elpa] externals/dash 6fc652d 331/426: Merge pull request #95 from Wilfred/shallow-copy-function, Phillip Lord, 2015/08/04