How to expand an expression along with a parameter tuple?

TommiT tommitissari at hotmail.com
Mon Jun 17 02:32:24 PDT 2013


On Monday, 17 June 2013 at 07:20:23 UTC, Ali Çehreli wrote:
>
> The following does not answer the question of expanding but at 
> least foo() receives [30, 70, 110] :)
>
> import std.stdio;
> import std.algorithm;
> import std.array;
> import std.range;
>
> int[] arr = [ 1, 3, 5, 7, 11 ];
>
> void foo(T)(T[] values...)
> {
>     writeln(values);
> }
>
> void bar(T)(T[] values...)
> {
>     foo(arr
>         .indexed(values)
>         .map!(a => a * 10)
>         .array);
> }
>
> void main()
> {
>     bar(1, 3, 4);
> }
>
> Ali

Yeah, that would work. I'd hate the overhead though.


More information about the Digitalmars-d-learn mailing list