A modern list api for Emacs. No 'cl required.
M-x package-install dash
Or you can just dump
dash.el in your load
If you want the function combinators, then also:
M-x package-install dash-functional
Using in a package
Add this to the big comment block at the top:
;; Package-Requires: ((dash "2.13.0"))
To get function combinators:
;; Package-Requires: ((dash "2.13.0") (dash-functional "1.2.0") (emacs "24"))
Upcoming breaking change!
- For backward compatibility reasons
-zipreturn a cons-cell instead of a list with two elements when called on two lists. This is a clunky API, and in an upcoming 3.0 release of Dash it will always return a list. If you rely on the cons-cell return value, use
Syntax highlighting of dash functions
Font lock of dash functions in emacs lisp buffers is now optional. Include this in your emacs settings to get syntax highlighting:
(eval-after-load 'dash '(dash-enable-font-lock))
All functions and constructs in the library are prefixed with a dash (-).
There are also anaphoric versions of functions where that makes sense, prefixed with two dashes instead of one.
-map takes a function to map over the list, you can also use
the anaphoric form with double dashes - which will then be executed
it exposed as the list item. Here's an example:
(-map (lambda (n) (* n n)) '(1 2 3 4)) ;; normal version (--map (* it it) '(1 2 3 4)) ;; anaphoric version
of course the original can also be written like
(defun square (n) (* n n)) (-map 'square '(1 2 3 4))
which demonstrates the usefulness of both versions.
[[ function-list ]]
[[ function-docs ]]
Yes, please do. Pure functions in the list manipulation realm only,
please. There's a suite of tests in
dev/examples.el, so remember to add
tests for your function, or I might break it later.
You'll find the repo at:
Run the tests with
Create the docs with
I highly recommend that you install these as a pre-commit hook, so that the tests are always running and the docs are always in sync:
cp pre-commit.sh .git/hooks/pre-commit
Oh, and don't edit
README.md directly, it is auto-generated.
From 2.12 to 2.13
- Various performance improvements.
-zipwill change in future so it always returns lists. Added
-zip-pairfor users who explicitly want the old behavior.
- Added lexical binding pragma to dash.el, fixes #130 in Emacs 24+.
- Fixed an issue with
--remove-lastwhere they modified their inputs (#158).
-cut <>is now treated as a function, consistent with SRFI 26 (#185)
From 2.11 to 2.12
- Add GNU ELPA support. (Phillip Lord)
-some-->macros. (Cam Saul)
-is-suffix?no longer destroys input list.
- Faster hashtable implementation for
- Improvements to docstrings and examples
From 2.10 to 2.11
- Lots of clean up wrt byte compilation, debug macros and tests
From 2.9 to 2.10
From 2.8 to 2.9
From 2.7 to 2.8
From 2.6 to 2.7
-zipnow supports more than two lists (Steve Lamb)
-table-flat(finite cartesian product)
-slicenow supports "step" argument
- Add functional combinators
From 2.5 to 2.6
From 2.4 to 2.5
- A few bugfixes
From 2.3 to 2.4
From 2.2 to 2.3
- Add tree operations (Matus Goljer)
- Make font-lock optional
From 2.1 to 2.2
From 2.0 to 2.1
- Add indexing operations (Matus Goljer)
From 1.8 to 2.0
- Split out
-on. (Matus Goljer)
From 1.7 to 1.8
From 1.6 to 1.7
From 1.5 to 1.6
From 1.4 to 1.5
From 1.3 to 1.4
From 1.2 to 1.3
From 1.1 to 1.2
- Some bugfixes
- Matus Goljer contributed lots of features and functions.
- Takafumi Arakaki contributed
- tali713 is the author of
- Víctor M. Valenzuela contributed
- Nic Ferrier contributed
- Wilfred Hughes contributed
- Emanuel Evans contributed
- Johan Andersson contributed
- Christina Whyte contributed
- Steve Lamb contributed
-zip-filland an n-ary version of
- Fredrik Bergroth made the
-letdestructuring and improved script for generating documentation.
- Mark Oteiza contributed the script to create an info manual.
- Vasilij Schneidermann contributed
- William West made
-fixfnmore robust at handling floats.
- Cam Saül contributed
New contributors are welcome. To ensure that dash.el can be distributed with ELPA or Emacs, we would request that all contributors assign copyright to the Free Software Foundation.
Copyright (C) 2012-2016 Free Software Foundation, Inc.
Authors: Magnar Sveen firstname.lastname@example.org 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/.