1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00

Reduce-right not limited by stack

* module/srfi/srfi-1.scm (reduce-right): Avoid blowing out the stack.
  Fixes #17485.
This commit is contained in:
Andy Wingo 2016-07-12 09:05:51 +02:00
parent 61b8794e04
commit 9c783616cc

View file

@ -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