fork download
  1. import std.stdio;
  2. import std.algorithm;
  3. import std.array;
  4.  
  5. bool pred(int x) {
  6. return x % 2 == 0;
  7. }
  8. int mapf(int x) {
  9. return x * x;
  10. }
  11.  
  12. void main()
  13. {
  14. auto x = [1,2,3,4,5,6,7];
  15. auto y = x.filter!(pred).map!(mapf);
  16. writeln(y);
  17. }
Success #stdin #stdout 0s 4332KB
stdin
Standard input is empty
stdout
[4, 16, 36]