On Monday, 17 June 2013 at 11:15:24 UTC, Artur Skawina wrote:
On 06/17/13 11:32, TommiT wrote:
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.
void bar(T...)(T values) {
T tmp;
foreach (i, ref v; values)
tmp[i] = arr[v]*10;
foo(tmp);
}
artur
Cool, I didn't know that you could create multiple variables like
that (T tmp).