[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 43dcd37 295/426: Only eval NUM in --dotimes once
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash 43dcd37 295/426: Only eval NUM in --dotimes once |
Date: |
Tue, 04 Aug 2015 19:38:23 +0000 |
branch: externals/dash
commit 43dcd37d4705b5559eef22635045ab4283ffb2e2
Author: Matus Goljer <address@hidden>
Commit: Matus Goljer <address@hidden>
Only eval NUM in --dotimes once
---
README.md | 2 +-
dash.el | 14 ++++++++------
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index 7aba5dc..445c41e 100644
--- a/README.md
+++ b/README.md
@@ -1371,7 +1371,7 @@ Returns nil, used for side-effects only.
#### -dotimes `(num fn)`
-Repeatedly calls `fn` (presumably for side-effects) passing in integers from 0
through n-1.
+Repeatedly calls `fn` (presumably for side-effects) passing in integers from 0
through `num-1`.
```cl
(let (s) (-dotimes 3 (lambda (n) (!cons n s))) s) ;; => '(2 1 0)
diff --git a/dash.el b/dash.el
index b38c1d3..9c2a928 100644
--- a/dash.el
+++ b/dash.el
@@ -92,16 +92,18 @@ Returns nil, used for side-effects only."
(put '-each-while 'lisp-indent-function 2)
(defmacro --dotimes (num &rest body)
- "Repeatedly executes BODY (presumably for side-effects) with `it` bound to
integers from 0 through n-1."
+ "Repeatedly executes BODY (presumably for side-effects) with `it` bound to
integers from 0 through NUM-1."
(declare (debug (form body))
(indent 1))
- `(let ((it 0))
- (while (< it ,num)
- ,@body
- (setq it (1+ it)))))
+ (let ((n (make-symbol "num")))
+ `(let ((,n ,num)
+ (it 0))
+ (while (< it ,n)
+ ,@body
+ (setq it (1+ it))))))
(defun -dotimes (num fn)
- "Repeatedly calls FN (presumably for side-effects) passing in integers from
0 through n-1."
+ "Repeatedly calls FN (presumably for side-effects) passing in integers from
0 through NUM-1."
(--dotimes num (funcall fn it)))
(put '-dotimes 'lisp-indent-function 1)
- [elpa] externals/dash c61fc34 417/426: Add -remove-first/last, -map-first/last, -replace-first/last, (continued)
- [elpa] externals/dash c61fc34 417/426: Add -remove-first/last, -map-first/last, -replace-first/last, Phillip Lord, 2015/08/04
- [elpa] externals/dash fb51f8f 304/426: Merge pull request #88 from steventlamb/topic/zip_cycle_pad, Phillip Lord, 2015/08/04
- [elpa] externals/dash d0c6fc0 371/426: Merge pull request #104 from fbergroth/linkify-docs, Phillip Lord, 2015/08/04
- [elpa] externals/dash c08fcba 299/426: Fixed documentation of `-last-item'., Phillip Lord, 2015/08/04
- [elpa] externals/dash f96196a 289/426: Merge pull request #75 from Fuco1/prefix, Phillip Lord, 2015/08/04
- [elpa] externals/dash afe2781 388/426: Merge pull request #109 from bbatsov/threading-indentation, Phillip Lord, 2015/08/04
- [elpa] externals/dash 6b64ea7 303/426: Add functions for flexibly zipping uneven lists, Phillip Lord, 2015/08/04
- [elpa] externals/dash cd137e0 310/426: `-slice` should not fill the returned list with nils if to > length, Phillip Lord, 2015/08/04
- [elpa] externals/dash 5219ac0 422/426: [-let] Eliminate useless re-binding of symbols when sources are immutable, Phillip Lord, 2015/08/04
- [elpa] externals/dash a06e66e 382/426: Add test for clean byte compilation, Phillip Lord, 2015/08/04
- [elpa] externals/dash 43dcd37 295/426: Only eval NUM in --dotimes once,
Phillip Lord <=
- [elpa] externals/dash 4ecfea6 296/426: Merge pull request #79 from Fuco1/debug-forms, Phillip Lord, 2015/08/04
- [elpa] externals/dash 624c501 306/426: Add `-table` and `-table-flat`, Phillip Lord, 2015/08/04
- [elpa] externals/dash cf7ca23 415/426: [Fix #97] Add -remove-item, Phillip Lord, 2015/08/04
- [elpa] externals/dash 2eefbec 386/426: Don't use an inline comment on a line of its own, Phillip Lord, 2015/08/04
- [elpa] externals/dash bbc1d9c 309/426: `--each-while` should also expose `it-index`, Phillip Lord, 2015/08/04
- [elpa] externals/dash 6bdcfa5 286/426: Add -split-on, -split-when, Phillip Lord, 2015/08/04
- [elpa] externals/dash bd85b7c 302/426: Make -zip support infinite (circular) lists, Phillip Lord, 2015/08/04
- [elpa] externals/dash 19fbc24 426/426: Fix anaphoric -spice-list macro, Phillip Lord, 2015/08/04
- [elpa] externals/dash 36b7f49 419/426: [-let] Reuse the ignore-place predicate, Phillip Lord, 2015/08/04
- [elpa] externals/dash 703bb59 297/426: Convert -zip to support variable-length arguments, Phillip Lord, 2015/08/04