Formatted output of range of tuples
Sag Academy via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Oct 13 05:54:13 PDT 2014
On Monday, 13 October 2014 at 09:20:27 UTC, monarch_dodra wrote:
> On Wednesday, 8 October 2014 at 23:28:34 UTC, bearophile wrote:
>> anonymous:
>>
>>> You can turn the tuples into ranges with `only`:
>>>
>>> writef("%(%(%s %)\n%)", zip(indexes, source).map!(t =>
>>> only(t.expand)));
>>
>> This is a nice idea. Expand can probably be replaced by a [].
>> I presume this works only if the types inside the tuple are
>> the same.
>
> Expand creates "returns" a TypeTuple though, so it's arguably
> "free". "[]" allocates a dynamic array, so is costly.
>
> On the flip side, "only" is *entirelly* by value, and carries
> all its arguments. If the tuple is big, then the range can
> become quite big.
> you are right man.
More information about the Digitalmars-d-learn
mailing list