Re: Range Expressions

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 16:51:13 UTC