fork download
  1. import std.range;
  2. import std.array;
  3. import std.algorithm;
  4. import std.stdio;
  5.  
  6. void foo(Range)(Range r) {
  7. r.fill(42);
  8. }
  9.  
  10. void main() {
  11. auto a = [1,2,3,4,5,6,7,8,9,10];
  12. auto m = 8;
  13. foo(a.indexed(iota(0,m,2)));
  14. // the same as: a.indexed(iota(0,m,2)).fill(42);
  15.  
  16. // [42, 2, 42, 4, 42, 6, 42, 8, 9, 10]
  17. writeln(a);
  18. }
Success #stdin #stdout 0s 4528KB
stdin
Standard input is empty
stdout
[42, 2, 42, 4, 42, 6, 42, 8, 9, 10]