Re: Issues with custom ranges
Wolfgang Corcoran-Mathe 20 Jul 2020 00:55 UTC
On 2020-07-19 18:12 -0400, John Cowan wrote:
> Can you elaborate a bit? I see why that change would be beneficial, but
> would it interfere with a lumpy indexer like one that returns the nth prime
> number?
The sequence of elements contained by a range is generated by the
indexer. The requirement that
(indexer lower-bound n) = (indexer (indexer lower-bound n) 0)
simply says that the sequence is independent of the lower bound.
Since the sequence of primes should be the same sequence, regardless
of where we start, we can expect this to hold of an indexer generating
primes. (If a is the nth prime greater than or equal to a lower
bound b, then the first prime greater than or equal to a is a.)
If a range's indexer satisfies this law, we can freely create
subranges by moving the lower bound about. It seems to be a
fundamental property of sequences, and, off the top of my head, I
can't think of a sequence that doesn't satisfy it. There may well
be exceptions. I'd appreciate any references on the topic.
In any case, I do think that the behavior of indexer functions needs
to be restricted in some way.
--
Wolfgang Corcoran-Mathe <xxxxxx@sigwinch.xyz>
"I don't really know much about Python. I only stole its object
system for Perl 5. I have since repented." --Larry Wall