Re: empty intervals John Cowan 29 Jul 2015 21:07 UTC

Bradley Lucier scripsit:

> Is (interval ‘#(1) ‘#(0)) allowed?  It’s also empty (in the
> sense that no multi-indices satisfy 1<= i<0); is it equal to (interval
> ‘#(1) ‘#(1))?  Or (interval ‘#(2) ‘#(0))?  Or (interval '#(1 1)
> ‘#(0 0))?  Or is (interval ‘#(0) ‘#(0)) a subset of (interval
> ‘#(1) ‘#(2))?  (In set theory, the answer is yes.)

My view is that they are all allowed and all distinct; they are
different forms of the same empty content.

> Is an empty set of one-indices "the same” (in whatever sense) as an
> empty set of two-indices?  (In set theory, yes.  In some other theories,
> I don’t know.)

I think that thinking of arrays or even array indices as sets is a mistake.
So these would be distinct: a vector (in the math, not the Scheme, sense)
is not a matrix.

> Perhaps if I understood the use of such things.  We already have
> scalars, why do we need zero-dimensional arrays?

For one thing, a zero-dimensional array is a box, a mutable container for
a value, not just a value.  For another, because Scheme does not normally
have polymorphic procedures, we can treat arrays and scalars uniformly if
zero-dimensional arrays are taken to be scalars.  In addition, Matlab,
NumPy, CL, and Julia all allow zero-dimensional arrays and treat them
identically, which is good precedent.  I don't claim to be a scientific
programmer, but doing what scientific programming languages do seems to
me to be the Right Thing.

> Or arrays that
> can’t return any values, because their underlying domains are empty?

Same basic answer, although this seems a little less justifiable.
However, it's probably good to do the Right Thing in edge cases.
Someone may need it.

--
John Cowan          http://www.ccil.org/~cowan        xxxxxx@ccil.org
Even a refrigerator can conform to the XML Infoset, as long as it has
a door sticker saying "No information items inside".  --Eve Maler