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

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

[elpa] externals/dash 07de30e 019/426: !mapcat macro, and with that: goo


From: Phillip Lord
Subject: [elpa] externals/dash 07de30e 019/426: !mapcat macro, and with that: goodbye 'cl!
Date: Tue, 04 Aug 2015 19:36:25 +0000

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

    !mapcat macro, and with that: goodbye 'cl!
---
 README.md |    2 --
 bang.el   |    6 ++----
 tests.el  |    6 ++++++
 3 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index 530575c..e2dda6c 100644
--- a/README.md
+++ b/README.md
@@ -4,8 +4,6 @@ The startings of a modern list api for Emacs.
 
 We're looking to Clojure for naming and signatures.
 
-Right now it relies on `cl` which should be one of the very first things we 
fix.
-
 ## Warning
 
 This is so much a work in progress that you should definitely not be using it 
yet.
diff --git a/bang.el b/bang.el
index 931b611..cc0e63d 100644
--- a/bang.el
+++ b/bang.el
@@ -25,8 +25,6 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
-
 (defun !--call-with-it (form-or-fn)
   (if (functionp form-or-fn)
       (list form-or-fn 'it)
@@ -75,8 +73,8 @@
 (defmacro !partial (fn &rest args)
   `(apply-partially ',fn ,@args))
 
-(defun !mapcat (fn list)
-  (apply !concat (!map fn list)))
+(defmacro !mapcat (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 3d9e701..b16295d 100644
--- a/tests.el
+++ b/tests.el
@@ -43,6 +43,12 @@
   (should (equal (!concat '(1) '(2)) '(1 2)))
   (should (equal (!concat '(1) '(2 3) '(4)) '(1 2 3 4))))
 
+(ert-deftest mapcat ()
+  "`!mapcat' applies the function to all elements of the list and then 
concatenates the result"
+  (should (equal (!mapcat list '(1 2 3)) '(1 2 3)))
+  (should (equal (!mapcat (lambda (item) (list 0 item)) '(1 2 3)) '(0 1 0 2 0 
3)))
+  (should (equal (!mapcat (list 0 it) '(1 2 3)) '(0 1 0 2 0 3))))
+
 (ert-deftest partial ()
   "`!partial' returns a function like fn where the first arguments are filled 
in"
   (should (equal (funcall (!partial + 5) 3) 8))



reply via email to

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