1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| let links: [[String]] = [ ["http://a1", "http://a2", "http://a3"], ["http://b1", "http://b2", "http://b3"], ["http://c1", "http://c2", "http://c3"], ] print(links)
let flapLink = links.flatMap { (exlinks: [String]) -> [String] in return exlinks } print(flapLink)
let d3: [[[Int]]] = [ [[1, 2, 3], [4, 5, 6], [7, 8, 9]], [[10, 11, 12], [13, 14, 15], [16, 17, 18]], [[19, 20, 21], [22, 23, 24], [25, 26, 27]], ]
let flapD1 = d3.flatMap { ele in return ele }
let flapD2 = d3.flatMap { ele in return ele.flatMap{$0} }
let colors = ["♥", "♠", "♦", "♣"] let numbers = ["J", "Q", "K", "A"] let cards = colors.flatMap { color in return numbers.map { num in return "\(color)-\(num)" } } print(cards)
|