fork download
  1. import std.stdio;
  2.  
  3. void func(T)(T[] a)
  4. {
  5. foreach(ref v; a)
  6. {
  7. v *= v;
  8. }
  9. }
  10.  
  11. void main()
  12. {
  13. int[] a = [1, 2, 3, 4, 5];
  14. a[1..4].func();
  15. writeln(a);
  16. }
Success #stdin #stdout 0.01s 2124KB
stdin
Standard input is empty
stdout
1 4 9 16 5