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

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

[elpa] externals/dash f9471e4 016/439: !concat done - one less 'cl depen


From: Phillip Lord
Subject: [elpa] externals/dash f9471e4 016/439: !concat done - one less 'cl dependency
Date: Tue, 04 Aug 2015 20:25:54 +0000

branch: externals/dash
commit f9471e411b220051a67484464ea6d5aeb8128d94
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>

    !concat done - one less 'cl dependency
---
 bang.el  |    6 +++---
 tests.el |   10 ++++++++--
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/bang.el b/bang.el
index a410bb6..ed5c430 100644
--- a/bang.el
+++ b/bang.el
@@ -59,8 +59,8 @@
         (list form-or-fn)
       `(let (acc it) ,form-or-fn))))
 
-(defun !concat (list)
-  (apply 'concatenate 'list list))
+(defun !concat (&rest lists)
+  (apply 'append (append lists '(nil))))
 
 (defalias '!select '!filter)
 (defalias '!reject 'remove-if)
@@ -68,7 +68,7 @@
 (defalias '!partial 'apply-partially)
 
 (defun !mapcat (fn list)
-  (!concat (!map fn list)))
+  (apply !concat (!map fn list)))
 
 (defun !uniq (list)
   "Return a new list with all duplicates removed.
diff --git a/tests.el b/tests.el
index 367ebeb..a7bc88f 100644
--- a/tests.el
+++ b/tests.el
@@ -27,8 +27,14 @@
 
   (should (equal (!reduce (lambda (memo item) (format "%s-%s" memo item)) '(1 
2 3)) "1-2-3"))
   (should (equal (!reduce (format "%s-%s" acc it) '(1 2 3)) "1-2-3"))
-  (should (equal (!reduce (format "%s-%s" acc it) '()) "nil-nil"))
-)
+  (should (equal (!reduce (format "%s-%s" acc it) '()) "nil-nil")))
+
+(ert-deftest concat ()
+  "`!concat' returns the concatenation of the elements in the supplied lists"
+  (should (equal (!concat) nil))
+  (should (equal (!concat '(1)) '(1)))
+  (should (equal (!concat '(1) '(2)) '(1 2)))
+  (should (equal (!concat '(1) '(2 3) '(4)) '(1 2 3 4))))
 
 (ert-deftest difference ()
   "`!difference' returns a new list of only elements in list1 that are not in 
list2."



reply via email to

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