fork download
  1. import std.stdio;
  2.  
  3. pure Type[] Reversed(Type)(const lazy Type[] Source)
  4. {
  5. if (Source.length <= 1) return Source;
  6. else
  7. {
  8. return Source[$-1] ~ Reversed(Source[0..$-1]);
  9. }
  10. }
  11.  
  12. pure Type[] Sort(Type)(const lazy Type[] Source)
  13. {
  14. if (Source.length <= 1) return Source;
  15.  
  16. else
  17. {
  18. const Type Pivot = Source[0];
  19.  
  20. Type[] Greater;
  21. Type[] Lesser;
  22.  
  23. for (Element; Source[1..$])
  24. {
  25. if (Element > Pivot) Greater ~= Element;
  26. else Lesser ~= Element;
  27. }
  28.  
  29. return Sort(Lesser) ~ Pivot ~ Sort(Greater);
  30. }
  31. }
  32.  
  33. void main()
  34. {
  35. writeln(Reversed("Hello, world!"));
  36. writeln(Sort("abidjfoakladfbdadfg9"));
  37. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.d(23): found ')' when expecting ';' following 'for condition'
prog.d(29): found 'return' when expecting ')'
stdout
Standard output is empty