Re: [swift-evolution] Nested for-in loops syntax

2016-07-17 Thread T.J. Usiyan via swift-evolution
re: cross (nod to Dave Abrahams for the clean implementation) /// 'Cartesian product' of two sequences public func cartesianProduct(lhs:Left, rhs:Right) -> [(Left.Iterator.Element, Right.Iterator.Element)] { return lhs.flatMap { x in rhs.map { (x, $0) } } } On Sun, Jul 17, 2016 at 11:54 AM,

Re: [swift-evolution] Nested for-in loops syntax

2016-07-17 Thread Nevin Brackett-Rozinsky via swift-evolution
I think this use-case is too narrow for dedicated syntax in the standard library. However, it should be simple enough for you to write your own function, let’s call it `unpack`, which produces a sequence that does what you want. While you’re at it you could also try writing a `cross` function

[swift-evolution] Nested for-in loops syntax

2016-07-17 Thread Maxim Bogdanov via swift-evolution
Hello, community. As I understood from documentation the only way to iterate multidimensional array or a dictionary (with for loop) is this: let multidimensionalDictionary = ["a":["b": "c"], "b":["c": "d"], "c": ["d": "e"]] for (key, value) in multidimensionalDictionary { for (nestedKey,