Re: empty intervals Per Bothner 29 Jul 2015 20:56 UTC


On 07/29/2015 01:21 PM, Bradley Lucier wrote:
> Is (interval ‘#(1) ‘#(0)) allowed?

I see no particular reason to allow it.  It's similar to
   (substring "abcde" 3 10)
You could say that this is the subset of "abcde" whouse indexes i
satisfy (and (>= i 3) (< i 10)).  However, we treat that as an error.

A plausible extension would be:
   (substring string interval)
which would be equivalent to:
   (substring string (interval-lower-bound interval 0)
                     (interval-upper-bound interval 0))
assuming (interval-dimension interval) is 1 (and an error if it is not).

I'm not saying we should do this; however, we might keep in mind that in
some implementations (such as Kawa) a vector of length N is also an
array such that (array-domain VEC) is (interval #(0) #(N)).

> 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.)
>
> Is an empty set of one-indices "the same” (in whatever sense) as an
> empty set of two-indices?

No. (interval ‘#(0) ‘#(0)) is different from (interval ‘#(1) ‘#(1)).
It may not matter, for most uses.

> (In set theory, yes.  In some other theories, I don’t know.)

APL-derived languages talk about "array theory" - which is different
from set theory.  Of course different APL-derived languages have
different variations of array theory - and their support for
general lower bounds varies.

> I understand that the base case of no multiplicands gives one as an
> answer, because it’s useful.  (That’s the same reason that $0^0=1$,
> that it’s a useful convention.)
>
> Perhaps if I understood the use of such things.  We already have
> scalars, why do we need zero-dimensional arrays?

In APL languages, a scalar is the same as 0-rank array.  In Scheme,
I'd say a zero-dimensional array is the same as a box, in the SRFI-111 sense.

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

Why do we need vectors or lists or strings that can't return any values,
because their underlying domains are empty?
--
	--Per Bothner
xxxxxx@bothner.com   http://per.bothner.com/