range=? Wolfgang Corcoran-Mathe (01 Sep 2020 17:26 UTC)
Re: range=? John Cowan (01 Sep 2020 17:28 UTC)
Re: range=? Marc Nieper-Wißkirchen (01 Sep 2020 17:30 UTC)

Re: range=? Marc Nieper-Wißkirchen 01 Sep 2020 17:29 UTC

Am Di., 1. Sept. 2020 um 19:27 Uhr schrieb Wolfgang Corcoran-Mathe
<xxxxxx@sigwinch.xyz>:
>
> In adding range=?, it's necessary to decide on the semantics of range
> equality.  An attempt follows.  Consider the two-range case for
> simplicity:
>
>     (range=? equal ra rb)
>
> If ra and rb both have zero length, the result is #t.  Otherwise, the
> result is #t iff their lengths are equal and their elements are
> pairwise equal in the sense of EQUAL.

Sounds good. But should be generalized to arbitrary many ranges.

> These semantics would equate some ranges which are internally
> different, e.g.:
>
>     (range=? = (numeric-range 0 4) (vector->range #(0 1 2 3)))
>     ; => #t

Looks good.

>     (range=? = (numeric-range 0 0)
>                (range 0 (lambda (i) (integer->char (+ i 65)))))
>     ; => #t

Likewise!

> The second example is slightly surprising, since the range have
> different types (loosely speaking).  In essence, these semantics
> identify all empty ranges with the same object, which seems like the
> Right and Schemely Thing here.  Comments?

An empty list of apples equals an empty list of pears!