Lazy range of hashes?

bearophile bearophileHUGS at lycos.com
Sat Aug 25 17:03:25 PDT 2012


Andrej Mitrovic:

> void main()
> {
>     int[string] x = ["foo":1];
>     int[string] y = ["bar":1];
>     assert("bar" in lazyHash(x, y));
> }
>
> Essentially it would turn into lazy 'in' checks, meaning first 
> opIn_r
> would be called for 'x', and then for 'y'.

This seems to work:

import std.algorithm;
void main() {
     auto x = ["foo": 1];
     auto y = ["bar": 2];
     //assert("bar" in lazyHash(x, y));
     assert(any!(h => "bar" in h)([x, y]));
}

Recently I have seen a lazy range struct able to replace that
[x,y]. I don't know if it's in Phobos already.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list