[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 78390f6 139/426: Merge pull request #12 from vemv/
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash 78390f6 139/426: Merge pull request #12 from vemv/master |
Date: |
Tue, 04 Aug 2015 19:37: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 5e72ff9 120/426: Include numbers in github ids., (continued)
- [elpa] externals/dash 5e72ff9 120/426: Include numbers in github ids., Phillip Lord, 2015/08/04
- [elpa] externals/dash a23aa4b 128/426: Add examples for -group-by, Phillip Lord, 2015/08/04
- [elpa] externals/dash 7f7ac33 130/426: Add Takafumi Arakaki to list of contributors., Phillip Lord, 2015/08/04
- [elpa] externals/dash 3044e83 129/426: Merge pull request #8 from tkf/group-by, Phillip Lord, 2015/08/04
- [elpa] externals/dash 85bd4e0 131/426: Add @tali713's -applify, Phillip Lord, 2015/08/04
- [elpa] externals/dash e9de223 116/426: Rename -replace-where to -map-when, Phillip Lord, 2015/08/04
- [elpa] externals/dash 002e4cd 132/426: Add tali713 to list of contributors., Phillip Lord, 2015/08/04
- [elpa] externals/dash 7e4ee06 135/426: 1.0.3, Phillip Lord, 2015/08/04
- [elpa] externals/dash e4521af 136/426: Add -repeat, Phillip Lord, 2015/08/04
- [elpa] externals/dash 69e054e 124/426: Switch around order of Contribute and Contributors parts in readme., Phillip Lord, 2015/08/04
- [elpa] externals/dash 78390f6 139/426: Merge pull request #12 from vemv/master,
Phillip Lord <=
- [elpa] externals/dash 1284bc6 134/426: Move .el files out of root., Phillip Lord, 2015/08/04
- [elpa] externals/dash da8dc62 138/426: Preserve newline at new-keywords, Phillip Lord, 2015/08/04
- [elpa] externals/dash 467dfa7 133/426: Add -map-indexed, Phillip Lord, 2015/08/04
- [elpa] externals/dash a196ac1 137/426: Fix -repeat, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9c5fbc5 143/426: nil is the default binding in let forms, Phillip Lord, 2015/08/04
- [elpa] externals/dash 8fe15ed 141/426: Group -repeat with -dotimes, Phillip Lord, 2015/08/04
- [elpa] externals/dash 98a82ca 142/426: DRY up -repeat with --dotimes, Phillip Lord, 2015/08/04
- [elpa] externals/dash 50e9f46 144/426: -cons* for making improper lists., Phillip Lord, 2015/08/04
- [elpa] externals/dash e083087 145/426: Merge pull request #13 from nicferrier/master, Phillip Lord, 2015/08/04
- [elpa] externals/dash 5161361 148/426: Clarify use of anaphoric form of -zip-with, Phillip Lord, 2015/08/04