fork download
  1. import std.conv, std.stdio;
  2.  
  3. string makeArray(T...)(T t) {
  4. auto xs = "";
  5.  
  6. auto hadFirst = false;
  7. foreach (x; t) {
  8. if (hadFirst) xs ~= ", ";
  9. hadFirst = true;
  10. xs ~= to!string(x);
  11. }
  12.  
  13. return "[" ~ xs ~ "]";
  14. }
  15.  
  16. void main() {
  17. writeln(mixin(makeArray(1, 2, 3, 4, 5)));
  18. }
  19.  
Success #stdin #stdout 0.01s 2124KB
stdin
Standard input is empty
stdout
1 2 3 4 5