emacs-elpa-diffs
[Top][All Lists]
Advanced

[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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]