From: David Kastrup <dak@gnu.org>
To: 17485@debbugs.gnu.org
Cc: David Kastrup <dak@gnu.org>
Subject: bug#17485: [PATCH 3/3] Reimplement reduce-right in srfi-1
Date: Tue, 3 Jun 2014 20:56:18 +0200 [thread overview]
Message-ID: <1401821778-19972-3-git-send-email-dak@gnu.org> (raw)
In-Reply-To: <1401821778-19972-1-git-send-email-dak@gnu.org>
* module/srfi/srfi-1.scm (reduce-right): Avoid use of drop-right in
connection with last as a single upfront reverse is more efficient and
simpler to understand.
Signed-off-by: David Kastrup <dak@gnu.org>
---
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 73d164a..6aa249a 100644
--- a/module/srfi/srfi-1.scm
+++ b/module/srfi/srfi-1.scm
@@ -573,10 +573,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
--
1.9.1
next prev parent reply other threads:[~2014-06-03 18:56 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-13 10:47 bug#17485: (srfi srfi-1) reduce-right does not scale, version 2.0.9 David Kastrup
2014-06-01 23:41 ` Mark H Weaver
2014-06-02 7:59 ` David Kastrup
2014-06-03 18:56 ` bug#17485: [PATCH 1/3] Let length+ return the length of dotted lists rather than #f David Kastrup
2014-06-03 18:56 ` bug#17485: [PATCH 2/3] Rewrite take-right, drop-right, drop-right! David Kastrup
2014-06-04 3:29 ` Mark H Weaver
2014-06-04 3:45 ` Mark H Weaver
2014-09-20 14:56 ` Mark H Weaver
2014-09-20 15:15 ` David Kastrup
2014-09-22 17:15 ` Mark H Weaver
2014-09-22 18:40 ` David Kastrup
2014-06-03 18:56 ` David Kastrup [this message]
2014-06-04 3:30 ` bug#17485: [PATCH 3/3] Reimplement reduce-right in srfi-1 Mark H Weaver
2014-06-04 3:42 ` bug#17485: [PATCH 1/3] Let length+ return the length of dotted lists rather than #f Mark H Weaver
2014-06-04 4:57 ` David Kastrup
2014-06-04 10:09 ` David Kastrup
2014-06-05 13:57 ` David Kastrup
2016-06-21 14:42 ` bug#17485: (srfi srfi-1) reduce-right does not scale, version 2.0.9 Andy Wingo
2016-06-21 15:31 ` David Kastrup
2016-07-12 7:07 ` Andy Wingo
2016-07-12 7:43 ` bug#17485: Ugh, well David Kastrup
2016-07-12 13:54 ` Andy Wingo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1401821778-19972-3-git-send-email-dak@gnu.org \
--to=dak@gnu.org \
--cc=17485@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).