Guest User

Untitled

a guest
Nov 17th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. var arr = [2, 3, 4, 5]
  2.  
  3. func apply(for array: [Int], transform: (Int) -> Int) -> [Int] {
  4. var result: [Int] = []
  5. for element in array {
  6. result.append(transform(element))
  7. }
  8. return result
  9. }
  10.  
  11. apply(for: arr) { $0 * 3 } //[6, 9, 12, 15]
Add Comment
Please, Sign In to add comment