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

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

[elpa] externals/dash e083087 145/439: Merge pull request #13 from nicfe


From: Phillip Lord
Subject: [elpa] externals/dash e083087 145/439: Merge pull request #13 from nicferrier/master
Date: Tue, 04 Aug 2015 20:27:17 +0000

branch: externals/dash
commit e08308715c6292b82b4d94055f03a3c389aca2e1
Merge: 9c5fbc5 50e9f46
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>

    Merge pull request #13 from nicferrier/master
    
    here's -cons*
---
 dash.el         |   18 ++++++++++++++++++
 dev/examples.el |    5 +++++
 2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/dash.el b/dash.el
index 0de6d42..2210506 100644
--- a/dash.el
+++ b/dash.el
@@ -218,6 +218,24 @@ through the REP function."
 Thus function FN should return a collection."
   (--mapcat (funcall fn it) list))
 
+(defun -cons* (&rest args)
+  "Makes a new list from the elements of ARGS.
+
+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))
+
 (defmacro --first (form list)
   "Anaphoric form of `-first'."
   (let ((n (make-symbol "needle")))
diff --git a/dev/examples.el b/dev/examples.el
index 2fbe146..d02c5a5 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -72,6 +72,11 @@
   (-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))
 
+(defexamples -cons*
+  (-cons* 1 2) => '(1 . 2)
+  (-cons* 1 2 3) => '(1 2 . 3)
+  (-cons* 1) => 1)
+
 (defexamples -any?
   (-any? 'even? '(1 2 3)) => t
   (-any? 'even? '(1 3 5)) => nil



reply via email to

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