Asssociative Array by Key-Value-Pair

bearophile via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Dec 15 10:46:20 PST 2014


H. S. Teoh:

> I implemented this before, but it got rejected because people 
> insisted
> that it must return a range of Tuple, but Tuple is defined in 
> Phobos and
> druntime can't have dependencies on Phobos. :-(
>
> Maybe I'll take another shot at this, since this question keeps 
> coming up.

One possible solution: have a hidden but documented runtime 
function that yields 2-item structs, and add a 
"std.range.byPairs" range and a "std.range.pairs" function to 
Phobos that yield the tuples (byPairs could use a cast to convert 
the runtime struct to the Phobos tuple).

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list