commit e6068e0ecd74b0d7fc85c61881f1e12be2994581
parent 0d8b512eecd214b0e3cf2bd719b9df723f2c77d5
Author: Yuval Langer <yuvallangerontheroad@gmail.com>
Date: Sun, 8 Oct 2023 19:25:22 +0300
Replace recursion with a cl-loop.
Diffstat:
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/super-duper-yes-or-no.el b/super-duper-yes-or-no.el
@@ -159,16 +159,18 @@ Examples:
\\='(sd--list-intersperse \\='(a) \\='d) returns \\='(a)
\\='(sd--list-intersperse \\='(a b) \\='d) returns \\='(a d b)
\\='(sd--list-intersperse \\='(a b c) \\='d) returns \\='(a d b d c)"
- (cond
- ((null input-list)
- '())
- ((null (cdr input-list))
- input-list)
- (t
+ (if (null input-list)
+ '()
(cons (car input-list)
- (cons intersperser
- (sd--list-intersperse (cdr input-list)
- intersperser))))))
+ (cl-loop
+ with new-list =
+ '()
+
+ for item
+ in (cdr input-list)
+
+ append
+ (list intersperser item)))))
(defun sd-yes-or-no-words-p (prompt)
"Ask user a yes or no question.