Re: Range Expressions

On Mon, 7 Dec 2020 at 15:22, Michael Kay <mike@saxonica.com> wrote:

> My inclination now is to drop "by" as an operator keyword, and instead to have a function slice(seq, X, Y, Z) which behaves like seq[X:Y:Z] in Python and Javascript, subject to variations in edge cases (I think Python and Javascript differ only the handling of step=0). X, Y, and Z can all be defaulted.

Does that tiny bit of sugar hurt Mike? I think not, and it does help.
Terse isn't always best?


>
> This doesn't leave you with a simple way of expressing a sequence of integers such as (10 by 2 to 20) ; but most of the time when you want this, it's because you're going to use those integers for indexing some other sequence. If you really want it you can write slice(10 to 20, (), (), 2); or if we allow keyword arguments, slice(10 to 20, step: 2).

Too loose? 10 to 20 by 2, tick.
10 to 2 by 20 - report an error?



regards

-- 
Dave Pawson
XSLT XSL-FO FAQ.
Docbook FAQ.

Received on Monday, 7 December 2020 15:48:42 UTC