[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 07de30e 019/439: !mapcat macro, and with that: goo
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash 07de30e 019/439: !mapcat macro, and with that: goodbye 'cl! |
Date: |
Tue, 04 Aug 2015 20:25:56 +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))
- [elpa] externals/dash e720428 010/439: Extract basic iteration form into macro., (continued)
- [elpa] externals/dash e720428 010/439: Extract basic iteration form into macro., Phillip Lord, 2015/08/04
- [elpa] externals/dash c229ba8 011/439: Rewrite to anaphoric filter function., Phillip Lord, 2015/08/04
- [elpa] externals/dash d870282 013/439: Add some tests, and fix the bugs they uncovered., Phillip Lord, 2015/08/04
- [elpa] externals/dash 3e0ef58 012/439: !filter can now take either a function or form (anaphoric), Phillip Lord, 2015/08/04
- [elpa] externals/dash b24d056 014/439: !map macro, Phillip Lord, 2015/08/04
- [elpa] externals/dash ed2e447 015/439: !reduce macro, Phillip Lord, 2015/08/04
- [elpa] externals/dash f9471e4 016/439: !concat done - one less 'cl dependency, Phillip Lord, 2015/08/04
- [elpa] externals/dash 4201ecd 017/439: Out with remove-if, in with !reject, Phillip Lord, 2015/08/04
- [elpa] externals/dash f5b16e3 018/439: Make !partial have the same quote-less API as the rest of bang., Phillip Lord, 2015/08/04
- [elpa] externals/dash a02b6c1 021/439: Add note about no 'cl required., Phillip Lord, 2015/08/04
- [elpa] externals/dash 07de30e 019/439: !mapcat macro, and with that: goodbye 'cl!,
Phillip Lord <=
- [elpa] externals/dash 52815c5 020/439: Add documentation, Phillip Lord, 2015/08/04
- [elpa] externals/dash 73204ca 022/439: Change !contains-p to !contains? to match clojure api., Phillip Lord, 2015/08/04
- [elpa] externals/dash 6c39876 003/439: Set up test framework with one basic test, Phillip Lord, 2015/08/04
- [elpa] externals/dash c0f2c8f 026/439: Test that it works with lexical binding., Phillip Lord, 2015/08/04
- [elpa] externals/dash 754dd0d 024/439: Create stand-alone anaphoric macros, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9e74cc0 027/439: Remove dead code., Phillip Lord, 2015/08/04
- [elpa] externals/dash 8eab3d1 028/439: Slight improvements to map., Phillip Lord, 2015/08/04
- [elpa] externals/dash d2dfb11 023/439: Use double-bang for anaphoric functions, Phillip Lord, 2015/08/04
- [elpa] externals/dash 85016d3 029/439: Fix quoted forms like `' in docs., Phillip Lord, 2015/08/04
- [elpa] externals/dash 6f0636f 032/439: Show only three first examples per function., Phillip Lord, 2015/08/04