On 2022-10-07 17:00 -0400, John Cowan wrote:
> On Fri, Oct 7, 2022 at 1:29 PM Wolfgang Corcoran-Mathe <xxxxxx@sigwinch.xyz>
> wrote:
>
> > As specified, range-any “returns the last [true] value returned by
> > 'pred'”. This is different SRFI 1 'any' and similar forms, which
> > return the *first* truthy value.
>
> It comes to the same thing, because any-ish procedures do not invoke the
> predicate again after it returns true. So "the last value returned by
> pred" is not the result of pred on the last value, which I think is how you
> are reading it; rather, it is exactly the same as "the first true value
> returned by pred".
I see what you mean, but I think this should be made clearer.
Here's SRFI 196 on range-any:
> Applies pred element-wise to the elements of the ranges and returns
> true if pred returns true on any application. Specifically it
> returns the last value returned by pred. Otherwise, #f is returned.
You could read this to mean that range-any has to run through all
the true results and return the last. At least one wise guy has
already done this. (I apparently forgot how 'any' works while
writing the range-any sample implementation. That, at least,
will have to be fixed.)
Compare this spec to those from othe SRFIs. In 134, ideque-any “invokes
pred on the elements of the ideque in order until one call returns a
true/false value, which is then returned”. Similarly, SRFI 1 says
that “the iteration stops when a true value is produced”.
range-any follows the same pattern, and SRFI 196 should be less
subtle on this point.
--
Wolfgang Corcoran-Mathe <xxxxxx@sigwinch.xyz>