[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 8fe15ed 141/439: Group -repeat with -dotimes
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash 8fe15ed 141/439: Group -repeat with -dotimes |
Date: |
Tue, 04 Aug 2015 20:27:15 +0000 |
branch: externals/dash
commit 8fe15ed4194de2a7d744613858eba4bac0d56eec
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>
Group -repeat with -dotimes
---
README.md | 24 ++++++++++++------------
dash.el | 4 ++--
dev/examples.el | 12 ++++++------
3 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/README.md b/README.md
index 8c858db..469f77d 100644
--- a/README.md
+++ b/README.md
@@ -30,6 +30,7 @@ Or you can just dump `dash.el` in your load path somewhere.
* [-each](#-each-list-fn) `(list fn)`
* [-each-while](#-each-while-list-pred-fn) `(list pred fn)`
* [-dotimes](#-dotimes-num-fn) `(num fn)`
+* [-repeat](#-repeat-n-x) `(n x)`
* [-take](#-take-n-list) `(n list)`
* [-drop](#-drop-n-list) `(n list)`
* [-take-while](#-take-while-pred-list) `(pred list)`
@@ -57,7 +58,6 @@ 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.
@@ -290,6 +290,17 @@ Repeatedly calls `fn` (presumably for side-effects)
passing in integers from 0 t
(let (s) (--dotimes 5 (!cons it s)) s) ;; => '(4 3 2 1 0)
```
+### -repeat `(n x)`
+
+Return a list with `x` repeated `n` times.
+Returns nil if `n` is less than 1.
+
+```cl
+(-repeat 3 :a) ;; => '(:a :a :a)
+(-repeat 1 :a) ;; => '(:a)
+(-repeat 0 :a) ;; => nil
+```
+
### -take `(n list)`
Returns a new list of the first `n` items in `list`, or all items if there are
fewer than `n`.
@@ -587,17 +598,6 @@ 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 04dde4e..540aff1 100644
--- a/dash.el
+++ b/dash.el
@@ -590,8 +590,8 @@ 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."
+ "Return a list with X repeated N times.
+Returns nil if N is less than 1."
(let ((ret nil))
(while (not (minusp (setq n (1- n))))
(!cons x ret))
diff --git a/dev/examples.el b/dev/examples.el
index d5d5b80..2fbe146 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -107,6 +107,12 @@
(let (s) (-dotimes 3 (lambda (n) (!cons n s))) s) => '(2 1 0)
(let (s) (--dotimes 5 (!cons it s)) s) => '(4 3 2 1 0))
+(defexamples -repeat
+ (-repeat 3 :a) => '(:a :a :a)
+ (-repeat 1 :a) => '(:a)
+ (-repeat 0 :a) => nil
+ (-repeat -1 :a) => nil)
+
(defexamples -take
(-take 3 '(1 2 3 4 5)) => '(1 2 3)
(-take 17 '(1 2 3 4 5)) => '(1 2 3 4 5))
@@ -239,9 +245,3 @@
(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 85bd4e0 131/439: Add @tali713's -applify, (continued)
- [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, 2015/08/04
- [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 <=
- [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
- [elpa] externals/dash 5161361 148/439: Clarify use of anaphoric form of -zip-with, Phillip Lord, 2015/08/04
- [elpa] externals/dash a7ee06e 149/439: Remove extra --separate definition, Phillip Lord, 2015/08/04
- [elpa] externals/dash f7a828f 147/439: Add -zip and -zip-with, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9c5fbc5 143/439: nil is the default binding in let forms, Phillip Lord, 2015/08/04