[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 0ff070b 169/426: Merge pull request #28 from shost
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash 0ff070b 169/426: Merge pull request #28 from shosti/master |
Date: |
Tue, 04 Aug 2015 19:37:29 +0000 |
branch: externals/dash
commit 0ff070bebb39ee9f351e4d9599a983b2a580933e
Merge: 6420bf8 30ac13b
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>
Merge pull request #28 from shosti/master
Add -insert-at
---
README.md | 10 ++++++++++
dash.el | 6 ++++++
dev/examples.el | 4 ++++
3 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md
index b91cb39..e98f711 100644
--- a/README.md
+++ b/README.md
@@ -39,6 +39,7 @@ Or you can just dump `dash.el` in your load path somewhere.
* [-take-while](#-take-while-pred-list) `(pred list)`
* [-drop-while](#-drop-while-pred-list) `(pred list)`
* [-split-at](#-split-at-n-list) `(n list)`
+* [-insert-at](#-insert-at-n-x-list) `(n x list)`
* [-split-with](#-split-with-pred-list) `(pred list)`
* [-separate](#-separate-pred-list) `(pred list)`
* [-partition](#-partition-n-list) `(n list)`
@@ -392,6 +393,15 @@ Returns a list of ((-take `n` `list`) (-drop `n` `list`)),
in no more than one p
(-split-at 17 '(1 2 3 4 5)) ;; => '((1 2 3 4 5) nil)
```
+### -insert-at `(n x list)`
+
+Returns a list with `x` inserted into `list` at position `n`.
+
+```cl
+(-insert-at 1 'x '(a b c)) ;; => '(a x b c)
+(-insert-at 12 'x '(a b c)) ;; => '(a b c x)
+```
+
### -split-with `(pred list)`
Returns a list of ((-take-while `pred` `list`) (-drop-while `pred` `list`)),
in no more than one pass through the list.
diff --git a/dash.el b/dash.el
index 81748ac..58fba98 100644
--- a/dash.el
+++ b/dash.el
@@ -411,6 +411,11 @@ FROM or TO may be negative."
(!cdr list)))
(list (nreverse result) list)))
+(defun -insert-at (n x list)
+ "Returns a list with X inserted into LIST at position N."
+ (let ((split-list (-split-at n list)))
+ (append (car split-list) (cons x (cadr split-list)))))
+
(defmacro --split-with (pred list)
"Anaphoric form of `-split-with'."
(let ((l (make-symbol "list"))
@@ -843,6 +848,7 @@ Returns nil if N is less than 1."
"--drop-while"
"-drop-while"
"-split-at"
+ "-insert-at"
"--split-with"
"-split-with"
"-partition"
diff --git a/dev/examples.el b/dev/examples.el
index 4482700..45ad8bf 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -150,6 +150,10 @@
(-split-at 3 '(1 2 3 4 5)) => '((1 2 3) (4 5))
(-split-at 17 '(1 2 3 4 5)) => '((1 2 3 4 5) nil))
+(defexamples -insert-at
+ (-insert-at 1 'x '(a b c)) => '(a x b c)
+ (-insert-at 12 'x '(a b c)) => '(a b c x))
+
(defexamples -split-with
(-split-with 'even? '(1 2 3 4)) => '(() (1 2 3 4))
(-split-with 'even? '(2 4 5 6)) => '((2 4) (5 6))
- [elpa] externals/dash 6ffdc93 157/426: Release 1.1.0, (continued)
- [elpa] externals/dash 6ffdc93 157/426: Release 1.1.0, Phillip Lord, 2015/08/04
- [elpa] externals/dash 1396102 165/426: Add -when-let and -if-let macros, Phillip Lord, 2015/08/04
- [elpa] externals/dash 6420bf8 167/426: Add Emanuel Evans to list of contributors, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9371ce4 164/426: Don't use the word collection when meaning list, Phillip Lord, 2015/08/04
- [elpa] externals/dash 30ac13b 168/426: Add -insert-at (closes #27), Phillip Lord, 2015/08/04
- [elpa] externals/dash c3dc883 166/426: Merge pull request #26 from shosti/when-if-let, Phillip Lord, 2015/08/04
- [elpa] externals/dash 2451f99 159/426: Merge pull request #20 from tarsius/master, Phillip Lord, 2015/08/04
- [elpa] externals/dash 79e3b92 172/426: Fix -when-let and -if-let docstrings, Phillip Lord, 2015/08/04
- [elpa] externals/dash d5c124d 170/426: Update @shosti's list of contributions., Phillip Lord, 2015/08/04
- [elpa] externals/dash 1754ae2 171/426: Typo, Phillip Lord, 2015/08/04
- [elpa] externals/dash 0ff070b 169/426: Merge pull request #28 from shosti/master,
Phillip Lord <=
- [elpa] externals/dash 73ac975 174/426: Merge pull request #29 from shosti/when-let-multi, Phillip Lord, 2015/08/04
- [elpa] externals/dash 6d328e4 175/426: Release 1.2.0, Phillip Lord, 2015/08/04
- [elpa] externals/dash f8db9e1 176/426: Avoid unnecessary copying for -insert-at, Phillip Lord, 2015/08/04
- [elpa] externals/dash 336e5a5 181/426: Release 1.3.1, Phillip Lord, 2015/08/04
- [elpa] externals/dash 6437adc 179/426: Release 1.3.0, Phillip Lord, 2015/08/04
- [elpa] externals/dash e870be8 173/426: Add -when-let* and -if-let*, Phillip Lord, 2015/08/04
- [elpa] externals/dash 4c8c410 180/426: Add new functions to syntax highlighting, Phillip Lord, 2015/08/04
- [elpa] externals/dash 3c546ab 178/426: Add -partition-in-steps & -partition-all-in-steps, Phillip Lord, 2015/08/04
- [elpa] externals/dash 1fc6679 185/426: Add -map-indexed to syntax highlighting, Phillip Lord, 2015/08/04
- [elpa] externals/dash 49de164 184/426: Declare debug-info for some macros, Phillip Lord, 2015/08/04