[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#17485: [PATCH 3/3] Reimplement reduce-right in srfi-1
From: |
Mark H Weaver |
Subject: |
bug#17485: [PATCH 3/3] Reimplement reduce-right in srfi-1 |
Date: |
Tue, 03 Jun 2014 23:30:25 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
David Kastrup <address@hidden> writes:
> * 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 <address@hidden>
> ---
> 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
Looks good to me.
Mark