guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] 01/01: Reduce-right not limited by stack


From: Andy Wingo
Subject: [Guile-commits] 01/01: Reduce-right not limited by stack
Date: Tue, 12 Jul 2016 07:07:59 +0000 (UTC)

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

commit 9c783616cc46eeb907c93b272dd6a6f36df9e204
Author: Andy Wingo <address@hidden>
Date:   Tue Jul 12 09:05:51 2016 +0200

    Reduce-right not limited by stack
    
    * module/srfi/srfi-1.scm (reduce-right): Avoid blowing out the stack.
      Fixes #17485.
---
 module/srfi/srfi-1.scm |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/module/srfi/srfi-1.scm b/module/srfi/srfi-1.scm
index d2531b5..670a3ae 100644
--- a/module/srfi/srfi-1.scm
+++ b/module/srfi/srfi-1.scm
@@ -557,10 +557,7 @@ then that's the return value."
 F is on two elements from LST, rather than one element and a given
 initial value.  If LST is empty, RIDENTITY is returned.  If LST
 has just one element then that's the return value."
-  (check-arg procedure? f reduce)
-  (if (null? lst)
-      ridentity
-      (fold-right f (last lst) (drop-right lst 1))))
+  (reduce f ridentity (reverse lst)))
 
 (define map
   (case-lambda



reply via email to

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