Grokking ranges: some new algorithms and ranges

Philippe Sigaud philippe.sigaud at gmail.com
Sun Nov 1 22:32:38 PST 2009


On Mon, Nov 2, 2009 at 05:13, Andrei Alexandrescu <
SeeWebsiteForEmail at erdani.org> wrote:

> Philippe Sigaud wrote:
>
>> Hello,
>>
>> (Uh, first time poster, so hi to all!)
>>
> [snip]
>
> Hi and welcome. This is very interesting work -
>

Thanks! And thank you for your good work there, and for the nuggets I found
while perusing std.* code.


> if you want to contribute it to Phobos at least for inspiration, you may
> want to put it in the public domain on your website or really anywhere on
> the Net.
>

Yes, I see that. I'll open an account on dsource.org tonight (It's 7 am
where I'm sitting).



>
> I'm thinking of factoring some of your APIs a bit, for example bimap is
> really an application of a binary function over two streams, one of which is
> a delay of the other.
>

You're perfectly right. Damn, and I saw that somewhere else. It's a way to
transform what a called array ranges into tuple-ranges.
Yes OK, the subjacent segmentation of ranges could be done by delaying some
copy. Um, it's more uniform this way, as everything could be zips and such
and it's even more general : you can create disjoint segments. Thanks!

That shouldn't be too difficult to code: make copies, drop first elements in
a ramp, zip them into a tuple-range, iterate on them, eventually with
stride.

By the way, if you know any easy/elegant way to transform a standard
function into a typecons.Tuple-accepting one, I'd be quite interested to see
it. I return tuples everywhere and, though doable, I don"t find that to easy
to plug another range on it. It's my main point of ugliness in the code,
from my pov.
At the begining, I just wanted to have some map!(tuplify!foo)(zip(ranges)),
but somehow it didn't work. I'll try that again.

Anyway, I'll go public, clean it somewhat and let this on the backburner
from some time, see what comes out of it.

And I've some bugs for std.range (mainly in chain). I gather the right way
to do that would be to put it on bugzilla? Is it OK to propose some slight
code change? (chain assumes opIndexAssign or .length I think, and has some
trouble if there is an infinite range somewhere, hasLength does not work for
ranges with .length enclosed in static if, which is a common case, etc.)

Bye,

   Philippe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20091102/2e7e09ca/attachment.html>


More information about the Digitalmars-d mailing list