Re: Range Expressions

And the range type is a good example of a *generic *type:

  range over integers

  range over angles

  range over temperatures

  range over distances

  range over days

  range over hours

  range over minutes

  range over seconds

etc, ..., etc

we could have a separate member in the   range record, that is the type of
the items in the range.

Thanks,
Dimitre

On Tue, Dec 1, 2020 at 8:50 AM Dimitre Novatchev <dnovatchev@gmail.com>
wrote:

> I would rather prefer this to be a system-provided  *record  *type. Name
> it   range
>
> record(start? xs:integer, end? xs:integer, step? xs:integer)
>
> Then one can provide a set of functions defined on the range type (and
> using the arrow operator comes handy here)
>
>      range?start
>   range?end
>   range?step
>
>   sequence($r as range) as xs:integer*
>   size($r as range) as xs:integer
>   index-at($r as range, $pos as xs:integer) as xs:integer
>   reverse($r as range) as range
>
> Thanks,
> Dimitre
>
> On Mon, Nov 30, 2020 at 6:05 AM Michael Kay <mike@saxonica.com> wrote:
>
>> Someone, I forget who, gave feedback suggesting making "by" a binary
>> operator so
>>
>> 1 to 10 by 2 means ((1 to 10) by 2) i.e. 1, 3, 5, 7, 9
>> 1 to 10 by -1 gives 10, 9, 8, 7, 6, 5, 4, 3, 2, 1
>> ("A", "B", "C", "D") by 2 gives ("A", "C")
>> ("A", "B", "C", "D") by -2 gives ("D", "B")
>>
>> I've adopted this suggestion in my latest draft.
>>
>> Michael Kay
>> Saxonica
>>
>
>

Received on Tuesday, 1 December 2020 18:07:32 UTC