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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/dash 49512b9 107/426: Simplify -take and -drop with --d


From: Phillip Lord
Subject: [elpa] externals/dash 49512b9 107/426: Simplify -take and -drop with --dotimes
Date: Tue, 04 Aug 2015 19:37:01 +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)



reply via email to

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