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))