branch: externals/dash
commit b661f96015142bc079144d90e87385dd5761b4b2
Merge: a84a434 f86d235
Author: Magnar Sveen <[email protected]>
Commit: Magnar Sveen <[email protected]>
Merge pull request #62 from Fuco1/consfix
Fix -cons*
---
dash.el | 12 +-----------
dev/examples.el | 4 +++-
2 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/dash.el b/dash.el
index 6999e64..2c77a11 100644
--- a/dash.el
+++ b/dash.el
@@ -280,17 +280,7 @@ Thus function FN should return a list."
The last 2 members of ARGS are used as the final cons of the
result so if the final member of ARGS is not a list the result is
a dotted list."
- (let (res)
- (--each
- args
- (cond
- ((not res)
- (setq res it))
- ((consp res)
- (setcdr res (cons (cdr res) it)))
- (t
- (setq res (cons res it)))))
- res))
+ (-reduce-r 'cons args))
(defun -snoc (list elem &rest elements)
"Append ELEM to the end of the list.
diff --git a/dev/examples.el b/dev/examples.el
index db71ca9..792883a 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -344,7 +344,9 @@
(defexamples -cons*
(-cons* 1 2) => '(1 . 2)
(-cons* 1 2 3) => '(1 2 . 3)
- (-cons* 1) => 1)
+ (-cons* 1) => 1
+ (-cons* 1 2 3 4) => '(1 2 3 . 4)
+ (apply '-cons* (number-sequence 1 10)) => '(1 2 3 4 5 6 7 8 9 . 10))
(defexamples -snoc
(-snoc '(1 2 3) 4) => '(1 2 3 4)