[Top][All Lists]

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

[Guile-commits] 01/01: Don't recurse in drop-right

From: Andy Wingo
Subject: [Guile-commits] 01/01: Don't recurse in drop-right
Date: Tue, 12 Jul 2016 13:54:09 +0000 (UTC)

wingo pushed a commit to branch stable-2.0
in repository guile.

commit af3796b11cebb1ec50bcf6056d604983f1f76b97
Author: Andy Wingo <address@hidden>
Date:   Tue Jul 12 15:53:40 2016 +0200

    Don't recurse in drop-right
    * module/srfi/srfi-1.scm (drop-right): Don't recurse, sadly, as we have
      a stack limit.
 module/srfi/srfi-1.scm |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/module/srfi/srfi-1.scm b/module/srfi/srfi-1.scm
index 670a3ae..356e295 100644
--- a/module/srfi/srfi-1.scm
+++ b/module/srfi/srfi-1.scm
@@ -374,10 +374,10 @@ end-of-list checking in contexts where dotted lists are 
 (define (drop-right lis k)
-  (let recur ((lag lis) (lead (drop lis k)))
+  (let lp ((lag lis) (lead (drop lis k)) (result '()))
     (if (pair? lead)
-       (cons (car lag) (recur (cdr lag) (cdr lead)))
-       '())))
+       (lp (cdr lag) (cdr lead) (cons (car lag) result))
+       (reverse result))))
 (define (take! lst i)
   "Linear-update variant of `take'."

reply via email to

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