[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 78390f6 139/439: Merge pull request #12 from vemv/
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash 78390f6 139/439: Merge pull request #12 from vemv/master |
Date: |
Tue, 04 Aug 2015 20:27:14 +0000 |
branch: externals/dash
commit 78390f6e29011224e3c969a82a7e36cdc2f8ce8b
Merge: 7e4ee06 da8dc62
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>
Merge pull request #12 from vemv/master
Add -repeat
---
README.md | 12 ++++++++++++
dash.el | 9 +++++++++
dev/examples.el | 6 ++++++
3 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md
index 3b030b2..dc25b20 100644
--- a/README.md
+++ b/README.md
@@ -57,6 +57,7 @@ Or you can just dump `dash.el` in your load path somewhere.
* [-->](#---x-form-rest-more) `(x form &rest more)`
* [!cons](#-cons-car-cdr) `(car cdr)`
* [!cdr](#-cdr-list) `(list)`
+* [-repeat](#-repeat-n-x) `(n x)`
There are also anaphoric versions of these functions where that makes sense,
prefixed with two dashes instead of one.
@@ -586,6 +587,17 @@ Destructive: Sets `list` to the cdr of `list`.
(let ((l '(3 5))) (!cdr l) l) ;; => '(5)
```
+### -repeat `(n x)`
+
+Return a list of `n` Xs.
+Attempts of retrieving a non-positive amount of Xs will return nil.
+
+```cl
+(-repeat 3 :a) ;; => '(:a :a :a)
+(-repeat 1 :a) ;; => '(:a)
+(-repeat 0 :a) ;; => nil
+```
+
## Contribute
diff --git a/dash.el b/dash.el
index 2eebff8..04dde4e 100644
--- a/dash.el
+++ b/dash.el
@@ -589,6 +589,14 @@ or with `-compare-fn' if that's non-nil."
(defalias '-contains-p '-contains?)
+(defun -repeat (n x)
+ "Return a list of N Xs.
+Attempts of retrieving a non-positive amount of Xs will return nil."
+ (let ((ret nil))
+ (while (not (minusp (setq n (1- n))))
+ (!cons x ret))
+ ret))
+
(eval-after-load "lisp-mode"
'(progn
(let ((new-keywords '(
@@ -671,6 +679,7 @@ or with `-compare-fn' if that's non-nil."
"-difference"
"-contains?"
"-contains-p"
+ "-repeat"
))
(special-variables '(
"it"
diff --git a/dev/examples.el b/dev/examples.el
index e9686ac..d5d5b80 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -239,3 +239,9 @@
(defexamples !cdr
(let ((l '(3))) (!cdr l) l) => '()
(let ((l '(3 5))) (!cdr l) l) => '(5))
+
+(defexamples -repeat
+ (-repeat 3 :a) => '(:a :a :a)
+ (-repeat 1 :a) => '(:a)
+ (-repeat 0 :a) => nil
+ (-repeat -1 :a) => nil)
- [elpa] externals/dash a23aa4b 128/439: Add examples for -group-by, (continued)
- [elpa] externals/dash a23aa4b 128/439: Add examples for -group-by, Phillip Lord, 2015/08/04
- [elpa] externals/dash c669282 123/439: Add @Fuco1 to list of contributors., Phillip Lord, 2015/08/04
- [elpa] externals/dash 7f7ac33 130/439: Add Takafumi Arakaki to list of contributors., Phillip Lord, 2015/08/04
- [elpa] externals/dash 467dfa7 133/439: Add -map-indexed, Phillip Lord, 2015/08/04
- [elpa] externals/dash 85bd4e0 131/439: Add @tali713's -applify, Phillip Lord, 2015/08/04
- [elpa] externals/dash 7e4ee06 135/439: 1.0.3, Phillip Lord, 2015/08/04
- [elpa] externals/dash 1284bc6 134/439: Move .el files out of root., Phillip Lord, 2015/08/04
- [elpa] externals/dash 1120417 127/439: Add -group-by, Phillip Lord, 2015/08/04
- [elpa] externals/dash 1c4e5d7 125/439: Remove eval from --reduce, it is evil., Phillip Lord, 2015/08/04
- [elpa] externals/dash 3044e83 129/439: Merge pull request #8 from tkf/group-by, Phillip Lord, 2015/08/04
- [elpa] externals/dash 78390f6 139/439: Merge pull request #12 from vemv/master,
Phillip Lord <=
- [elpa] externals/dash 0731333 140/439: Add @vemv to list of contributors, Phillip Lord, 2015/08/04
- [elpa] externals/dash 002e4cd 132/439: Add tali713 to list of contributors., Phillip Lord, 2015/08/04
- [elpa] externals/dash 98a82ca 142/439: DRY up -repeat with --dotimes, Phillip Lord, 2015/08/04
- [elpa] externals/dash 8fe15ed 141/439: Group -repeat with -dotimes, Phillip Lord, 2015/08/04
- [elpa] externals/dash e4521af 136/439: Add -repeat, Phillip Lord, 2015/08/04
- [elpa] externals/dash e083087 145/439: Merge pull request #13 from nicferrier/master, Phillip Lord, 2015/08/04
- [elpa] externals/dash 50e9f46 144/439: -cons* for making improper lists., Phillip Lord, 2015/08/04
- [elpa] externals/dash a196ac1 137/439: Fix -repeat, Phillip Lord, 2015/08/04
- [elpa] externals/dash da8dc62 138/439: Preserve newline at new-keywords, Phillip Lord, 2015/08/04
- [elpa] externals/dash fb75a7f 146/439: Add @nicferrier to list of contributors., Phillip Lord, 2015/08/04