[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 49512b9 107/439: Simplify -take and -drop with --d
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash 49512b9 107/439: Simplify -take and -drop with --dotimes |
Date: |
Tue, 04 Aug 2015 20:26:57 +0000 |
branch: externals/dash
commit 49512b96f4863868381aff5005774b2d50746499
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>
Simplify -take and -drop with --dotimes
---
dash.el | 12 ++++--------
1 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/dash.el b/dash.el
index 18ebb54..a3f6855 100644
--- a/dash.el
+++ b/dash.el
@@ -244,21 +244,17 @@ Alias: `-every?'"
(defalias '-none-p '-none?)
(defalias '--none-p '--none?)
-;; simplify with a --dotimes
(defun -take (n list)
"Returns a new list of the first N items in LIST, or all items if there are
fewer than N."
(let (result)
- (while (and list (> n 0))
- (!cons (car list) result)
- (!cdr list)
- (setq n (1- n)))
+ (--dotimes n (when list
+ (!cons (car list) result)
+ (!cdr list)))
(nreverse result)))
(defun -drop (n list)
"Returns the tail of LIST without the first N items."
- (while (and list (> n 0))
- (!cdr list)
- (setq n (1- n)))
+ (--dotimes n (!cdr list))
list)
(defmacro --take-while (form list)
- [elpa] externals/dash dc6f46c 098/439: Simplify docs-generation using dash., (continued)
- [elpa] externals/dash dc6f46c 098/439: Simplify docs-generation using dash., Phillip Lord, 2015/08/04
- [elpa] externals/dash f1c8453 083/439: Rename to dash., Phillip Lord, 2015/08/04
- [elpa] externals/dash eacb6f2 092/439: Docs: Better generation of github urls., Phillip Lord, 2015/08/04
- [elpa] externals/dash 12ed9f6 100/439: Add destructive operations !cons og !cdr, Phillip Lord, 2015/08/04
- [elpa] externals/dash 79b56cc 101/439: Use --each, !cons and !cdr to simplify implementations., Phillip Lord, 2015/08/04
- [elpa] externals/dash 81a3247 104/439: Let -each and -each-while take multiple forms., Phillip Lord, 2015/08/04
- [elpa] externals/dash ba60707 103/439: Use --each-while to simplify implementations., Phillip Lord, 2015/08/04
- [elpa] externals/dash eb50d17 106/439: Add Melpa back in., Phillip Lord, 2015/08/04
- [elpa] externals/dash 4fedd2e 099/439: Add -partition and -partition-all, Phillip Lord, 2015/08/04
- [elpa] externals/dash 38eed45 095/439: Add rainbow-dash, Phillip Lord, 2015/08/04
- [elpa] externals/dash 49512b9 107/439: Simplify -take and -drop with --dotimes,
Phillip Lord <=
- [elpa] externals/dash ed47814 105/439: Add -dotimes, Phillip Lord, 2015/08/04
- [elpa] externals/dash a08fc14 102/439: Add -each-while, Phillip Lord, 2015/08/04
- [elpa] externals/dash c56925a 111/439: Add font-lock for new functions and the `it` token., Phillip Lord, 2015/08/04
- [elpa] externals/dash a336d78 112/439: Add -only-some?, Phillip Lord, 2015/08/04
- [elpa] externals/dash 03370ea 108/439: Simplify examples-to-docs and examples-to-tests with dash, Phillip Lord, 2015/08/04
- [elpa] externals/dash ba80875 109/439: Nice indentation for --each, --each-while and --dotimes, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9a3dfdd 113/439: Name parameter PRED when function expects predicate., Phillip Lord, 2015/08/04
- [elpa] externals/dash a081c72 114/439: Fix tests., Phillip Lord, 2015/08/04
- [elpa] externals/dash 9faa422 115/439: Add -partition-by, Phillip Lord, 2015/08/04
- [elpa] externals/dash 51ddc13 110/439: Nice indentation for threading macros., Phillip Lord, 2015/08/04