fork download
  1. import std.stdio;
  2. import std.algorithm.iteration;
  3. import std.container.slist;
  4.  
  5. void main()
  6. {
  7. auto x = SList!int(1, 2, 3, 5, 7, 9);
  8. auto y = SList!int();
  9.  
  10. foreach(el; x) {
  11. y.insert(el);
  12. }
  13.  
  14. writefln("x = %s", x[]);
  15. writefln("reverse = %s", y[]);
  16. }
Success #stdin #stdout 0s 2700KB
stdin
Standard input is empty
stdout
x = [1, 2, 3, 5, 7, 9]
reverse = [9, 7, 5, 3, 2, 1]