A pass() identity range?

D Lark dlark at example.com
Thu Dec 2 11:35:53 UTC 2021


On Wednesday, 2 January 2013 at 18:49:06 UTC, H. S. Teoh wrote:
> On Wed, Jan 02, 2013 at 07:19:31PM +0100, bearophile wrote:
>> H. S. Teoh:
> [...]
>> >but I thought tee() might be a better name.
>> 
>> Python programmers have this "tee":
>> 
>> http://docs.python.org/3/library/itertools.html#itertools.tee
> [...]
>
> Hmm. But isn't that just the same as repeatedly calling .save 
> with D's forward ranges?
>
>
> T

Not really, the python itertools.tee affords a sort of 'save' on 
*inputRanges* (all python iterators roughly model inputRanges, 
and nothing more) hence letting you simulate forwardRange: you 
just have to promise not to touch the underlying range directly 
after a call to itertools.tee and instead work with the resulting 
split ranges provided.
I am a newcomer to D and I am looking for equivalent 
functionality in phobos (so far I have not found). Is there a way 
to convert inputRanges into forwardRanges, at the cost of extra 
memory?
PS: thanks for your range calendar tutorial!


More information about the Digitalmars-d-learn mailing list