interval-foldl and interval-foldr Bradley Lucier (17 Aug 2022 15:45 UTC)
Re: interval-foldl and interval-foldr John Cowan (17 Aug 2022 21:11 UTC)
Re: interval-foldl and interval-foldr Marc Nieper-Wißkirchen (17 Aug 2022 21:29 UTC)
Re: interval-foldl and interval-foldr Bradley Lucier (17 Aug 2022 21:34 UTC)

Re: interval-foldl and interval-foldr Marc Nieper-Wißkirchen 17 Aug 2022 21:28 UTC

In mathematics, an interval is usually characterized as a
(topologically) connected subset of the real line. Thus, I would also
prefer a different name, like "range", say. I also find naming
cartesian powers of intervals intervals misleading. I would call such
cartesian powers cuboids, for example.

In fact, I would prefer that indices can be arbitrary ordered finite
sets. This helps type-safety. The presentation matrix of a linear map
with respect to one pair of bases could then have a different type
than the presentation matrix of the same linear map but with respect
to a different pair of bases. It would be a type error to add these
two presentation matrixes (which would make no sense mathematically).

So a set of three indices could be 1, 2, 3, or 'x, 'y, 'z. But also
'r, 'phi, 'z. (Think of cartesian and cylindrical coordinates here.)

Am Mi., 17. Aug. 2022 um 23:11 Uhr schrieb John Cowan <xxxxxx@ccil.org>:
>
> I agree that these foldl and foldr procedures make sense.
>
> I am a little troubled (I forget if I mentioned this before) by the use of the word "interval" in this connection, as it conflicts with intervals as in interval arithmetic.  An interval in that sense is everything that falls between an upper bound and a lower bound, inclusive or exclusive, but does not have to have denumerable members, much less integer ones.  Can anyone think of an alternative, or is it too late?
>
> On Wed, Aug 17, 2022 at 11:46 AM Bradley Lucier <xxxxxx@math.purdue.edu> wrote:
>>
>> The library has long had %%interval-foldl as an internal routine.
>>
>> After the recent rewrite, %%interval-foldl was used to implement
>> array-foldl, array-reduce, array-for-each, and interval-for-each, and a
>> new %%interval-foldr was written to support array-foldr.
>>
>> After seeing how useful %%interval-foldl and %%interval-foldr proved to
>> be in processing data in order over intervals and arrays, I decided to
>> publicize these routines as interval-foldl and interval-foldr.
>>
>> It's not quite parallel to the for/* syntax that Racket has for loops,
>> but it can be used quite similarly.
>>
>> Brad