Created
August 11, 2015 03:09
-
-
Save droyad/a778b4ba1ebc298d4100 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
var items = new [] { | |
new[] {"A", "B"}, | |
new[] {"1", "2", "3"}, | |
new[] {"*", "+"} | |
}; | |
//items.Aggregate((memo, i) => memo.SelectMany (m => i.Concat(new[]{ m}).ToArray()).ToArray()).Dump(); | |
var currentList = new List<List<string>>(items[0].Select (i => new List<string> { i})); | |
foreach(var genArg in items.Skip(1)) | |
{ | |
var newList = new List<List<string>>(); | |
foreach(var currentItem in currentList) | |
foreach(var newThing in genArg) | |
{ | |
var newItem = new List<string>(currentItem); | |
newItem.Add(newThing); | |
newList.Add(newItem); | |
} | |
currentList = newList; | |
} | |
currentList.Dump(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment