- From: Dimitre Novatchev <dnovatchev@gmail.com>
- Date: Tue, 1 Dec 2020 13:01:33 -0800
- To: Michael Kay <mike@saxonica.com>
- Cc: public-xslt-40@w3.org
- Message-ID: <CAK4KnZdi4PXiz+NuEm_tU8s8wzJ2ipmczAsWh_XYsVrwV53MqA@mail.gmail.com>
> Apart from anything else, it loses the idioms in the current language that rely on a range being a sequence of integers, > enabling familiar constructs such as x[position() = 1 to 10]. Well, there is nothing wrong with series of time periods in a total time range. Maybe we can have a lifted overload of range, providing a function that, when applied on the provided as integers start, end and step, will produce the actual start, end and step for the actual range: range($startBase as xs:integer, $endBase as xs:integer, $stepBase as xs:integer, $provider as function(xs:integer) as item() ) as item()* So, the provider() or better name, will convert the integers to whatever typed-data we need. Thanks, Dimitre On Tue, Dec 1, 2020 at 11:31 AM Michael Kay <mike@saxonica.com> wrote: > This feels to me like a step too far. If we had an object-oriented > language with strong infrastructure for new types like this then it might > be the right thing to do, but at present it doesn't blend in well. Apart > from anything else, it loses the idioms in the current language that rely > on a range being a sequence of integers, enabling familiar constructs such > as x[position() = 1 to 10]. > > Michael Kay > Saxonica > > On 1 Dec 2020, at 16:50, 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 >> > > > -- Cheers, Dimitre Novatchev --------------------------------------- Truly great madness cannot be achieved without significant intelligence. --------------------------------------- To invent, you need a good imagination and a pile of junk ------------------------------------- Never fight an inanimate object ------------------------------------- To avoid situations in which you might make mistakes may be the biggest mistake of all ------------------------------------ Quality means doing it right when no one is looking. ------------------------------------- You've achieved success in your field when you don't know whether what you're doing is work or play ------------------------------------- To achieve the impossible dream, try going to sleep. ------------------------------------- Facts do not cease to exist because they are ignored. ------------------------------------- Typing monkeys will write all Shakespeare's works in 200yrs.Will they write all patents, too? :) ------------------------------------- Sanity is madness put to good use. ------------------------------------- I finally figured out the only reason to be alive is to enjoy it.
Received on Tuesday, 1 December 2020 21:02:02 UTC