Advertisement
Guest User

Untitled

a guest
Jul 6th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
D 0.31 KB | None | 0 0
  1. import std.stdio;
  2.  
  3. int[] addMul(int[] slice, int add, int multiplier)
  4. {
  5.     int[] result;
  6.  
  7.     foreach (value; slice) {
  8.         result ~= (value + add) * multiplier;
  9.     }
  10.  
  11.     return result;
  12. }
  13.  
  14. void main(string[ ] args)
  15. {
  16.     auto values = [ 1, 2, 3, 4, 5 ];
  17.     writeln(values.addMul(1, 10));
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement