Implementation of reduce-right in SRFI 1 TAKIZAWA Yozo (28 Dec 2021 08:50 UTC)
Re: Implementation of reduce-right in SRFI 1 Arthur A. Gleckler (08 Jan 2022 16:47 UTC)
Re: Implementation of reduce-right in SRFI 1 Alex Shinn (09 Jan 2022 23:20 UTC)
Re: Implementation of reduce-right in SRFI 1 John Cowan (10 Jan 2022 04:13 UTC)
Re: Implementation of reduce-right in SRFI 1 Alex Shinn (10 Jan 2022 04:43 UTC)
Re: Implementation of reduce-right in SRFI 1 Marc Nieper-Wißkirchen (10 Jan 2022 12:02 UTC)
Re: Implementation of reduce-right in SRFI 1 Arthur A. Gleckler (10 Jan 2022 16:31 UTC)
Re: Implementation of reduce-right in SRFI 1 Arthur A. Gleckler (23 Oct 2022 01:45 UTC)
Re: Implementation of reduce-right in SRFI 1 TAKIZAWA Yozo (10 Jan 2022 11:54 UTC)

Re: Implementation of reduce-right in SRFI 1 Marc Nieper-Wißkirchen 10 Jan 2022 12:02 UTC

We can still make changes to (scheme list) as part of R7RS-large if necessary.

Otherwise, I agree with Alex's points. Only when no side effects are
involved, reduce-right should be equivalent to fold-right.

Am Mo., 10. Jan. 2022 um 05:43 Uhr schrieb Alex Shinn <xxxxxx@gmail.com>:
>
> Although I agree that would be preferable, it's not the
> implementations that matter but the uses.  If there are any existing
> programs passing non-associative procedures to reduce(-right), then
> your proposal would break them.
>
> --
> Alex
>
> On Mon, Jan 10, 2022 at 1:13 PM John Cowan <xxxxxx@ccil.org> wrote:
> >
> > +1.
> >
> > I note that SRFI 1, unlike some versions of reduce(-right), doesn't require _f_ to be associative.  If a non-associative _f_ were made an error, it would allow reduction, unlike folding, to be done in parallel.  I don't know if it's too late to make this change or not.  It wouldn't affect any existing implementations.
> >
> > On Sun, Jan 9, 2022 at 6:21 PM Alex Shinn <xxxxxx@gmail.com> wrote:
> >>
> >> This was from an issue first reported in Chibi.
> >>
> >> The definition of `reduce` is quite clear that it only uses the
> >> `ridentity` in the empty list case.
> >> It further provides a detailed note explaining this and the motivation.
> >>
> >> The definition of `reduce-right` both in the expansions given and the summary:
> >>
> >>   "... in other words, we compute (fold-right f ridentity list)"
> >>
> >> seems to make it clear that the ridentity is used even in the
> >> non-empty list case.
> >>
> >> However, this makes no sense, because then there is no difference
> >> between fold-right and reduce-right.
> >> I think it's clear the same note was intended for reduce-right as for reduce.
> >>
> >> Also, the reduce-right definition incorrectly expands into reduce:
> >>
> >>   (reduce-right f ridentity '(e1 e2 ...)) =
> >>     (f e1 (reduce f ridentity (e2 ...)))
> >>
> >> At least there should be an errata to replace that expansion with
> >> `reduce-right`.
> >> Arguably it should be modified further:
> >>
> >>   (reduce-right f ridentity '(e1 e2 ...)) =
> >>     (fold-right f e1 (e2 ...))
> >>
> >> updating the summary to something like
> >>
> >>   "... in other words, we compute (fold-right f ridentity list), but
> >> as with reduce only use ridentity in the empty list case."
> >>
> >> --
> >> Alex
> >>
> >> On Sun, Jan 9, 2022 at 1:48 AM Arthur A. Gleckler <xxxxxx@speechcode.com> wrote:
> >> >
> >> > On Tue, Dec 28, 2021 at 12:50 AM TAKIZAWA Yozo <xxxxxx@nbk.bz> wrote:
> >> >>
> >> >> Although this is not a specification topic but implementation, I send
> >> >> it to the list as a related issue to confirm or clarify.
> >> >
> >> >
> >> > Thanks for the question.  Would you mind showing some examples to make the question clearer?  It would be great if you could show examples that differ between Scheme implementations.
> >> >
> >> > Thanks, and happy new year.