[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 302c8ea 001/439: Initial commit.
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash 302c8ea 001/439: Initial commit. |
Date: |
Tue, 04 Aug 2015 20:25:38 +0000 |
branch: externals/dash
commit 302c8ea0668b9f7653d7bedfbe69d02fc95b80a7
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>
Initial commit.
---
README.md | 32 ++++++++++++++++++++
bang.el | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 129 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..88f07be
--- /dev/null
+++ b/README.md
@@ -0,0 +1,32 @@
+# bang.el
+
+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.
+
+## License
+
+;; Copyright (C) 2012 Magnar Sveen, Joel McCracken
+
+;; Authors: Magnar Sveen <address@hidden>
+;; Joel McCracken
+;; Keywords: lists
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
diff --git a/bang.el b/bang.el
new file mode 100644
index 0000000..b1bd793
--- /dev/null
+++ b/bang.el
@@ -0,0 +1,97 @@
+;;; bang.el --- A modern list library for Emacs
+
+;; Copyright (C) 2012 Magnar Sveen, Joel McCracken
+
+;; Authors: Magnar Sveen <address@hidden>
+;; Joel McCracken
+;; Keywords: lists
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; The startings of a modern list api for Emacs.
+
+;;; Code:
+
+(eval-when-compile (require 'cl))
+
+(defvar !compare-fn nil
+ "Tests for equality use this function or `equal' if this is nil.
+It should only be set using dynamic scope with a let, like:
+(let ((!compare-fn =)) (!union numbers1 numbers2 numbers3)")
+
+(defun !concat (list)
+ (apply 'concatenate 'list list))
+
+(defalias '!map 'mapcar)
+
+(defalias '!filter 'remove-if-not)
+(defalias '!select 'remove-if-not)
+(defalias '!reject 'remove-if)
+
+(defalias '!partial 'apply-partially)
+
+(defun !mapcat (fn list)
+ (!concat (!map fn list)))
+
+(defun !uniq (list)
+ "Return a new list with all duplicates removed.
+The test for equality is done with `equal',
+or with `!compare-fn' if that's non-nil."
+ (let (result)
+ (while list
+ (add-to-list 'result (car list) nil !compare-fn)
+ (setq list (cdr list)))
+ (reverse result)))
+
+(defun !intersection (list list2)
+ "Return a new list containing only the elements that are members of both
LIST and LIST2.
+The test for equality is done with `equal',
+or with `!compare-fn' if that's non-nil."
+ (let (result)
+ (while list
+ (when (!contains-p list2 (car list))
+ (setq result (cons (car list) result)))
+ (setq list (cdr list)))
+ (reverse result)))
+
+(defun !difference (list list2)
+ "Return a new list with only the members of LIST that are not in LIST2.
+The test for equality is done with `equal',
+or with `!compare-fn' if that's non-nil."
+ (let (result)
+ (while list
+ (unless (!contains-p list2 (car list))
+ (setq result (cons (car list) result)))
+ (setq list (cdr list)))
+ (reverse result)))
+
+(defun !contains-p (list element)
+ "Return whether LIST contains ELEMENT.
+The test for equality is done with `equal',
+or with `!compare-fn' if that's non-nil."
+ (cond
+ ((null !compare-fn) (member element list))
+ ((eq !compare-fn 'eq) (memq element list))
+ ((eq !compare-fn 'eql) (memql element list))
+ (t
+ (let ((lst list))
+ (while (and lst
+ (not (funcall !compare-fn element (car lst))))
+ (setq lst (cdr lst)))
+ lst))))
+
+(provide 'bang)
+;;; bang.el ends here
- [elpa] branch externals/dash created (now eadb265), Phillip Lord, 2015/08/04
- [elpa] externals/dash 300fbc6 002/439: Remove lisp-comments from README, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9a34da8 004/439: Add config for travis-ci, Phillip Lord, 2015/08/04
- [elpa] externals/dash 302c8ea 001/439: Initial commit.,
Phillip Lord <=
- [elpa] externals/dash 14673a6 007/439: Use nreverse for performance reasons., Phillip Lord, 2015/08/04
- [elpa] externals/dash 7b52951 008/439: Add watchr script to get autotest, Phillip Lord, 2015/08/04
- [elpa] externals/dash 93957f0 006/439: Add travis status icon to README, Phillip Lord, 2015/08/04
- [elpa] externals/dash ad44aee 009/439: Add more tests., Phillip Lord, 2015/08/04
- [elpa] externals/dash 065f76b 005/439: Use ert.el to run on Emacs 23 as well., Phillip Lord, 2015/08/04
- [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