From fae51b589ba761500bb0e478ddc24589e86ca4cb Mon Sep 17 00:00:00 2001 From: Zach Shaftel Date: Wed, 18 Sep 2019 17:37:17 -0400 Subject: [PATCH] Make -inits not destroy its argument --- dash.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dash.el b/dash.el index f48c517..dbdc733 100644 --- a/dash.el +++ b/dash.el @@ -2342,7 +2342,12 @@ or with `-compare-fn' if that's non-nil." (defun -inits (list) "Return all prefixes of LIST." - (nreverse (-map 'reverse (-tails (nreverse list))))) + (let ((acc nil) + (ret (list nil))) + (--each list + (!cons it acc) + (!cons (reverse acc) ret)) + (nreverse ret))) (defun -tails (list) "Return all suffixes of LIST"