Created
March 24, 2016 18:10
-
-
Save DeepSky8/e3eb573c07563f7a23b1 to your computer and use it in GitHub Desktop.
This compiles, and it makes perfect sense from a technical standpoint. But I don't know how I figured it out. And that bothers me.
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace SelectSoMany | |
{ | |
public static class Program | |
{ | |
static void Main(string[] args) | |
{ | |
} | |
public static IEnumerable<T2> SelectTooMany<T, T2>(this IEnumerable<T> xs, Func<T, IEnumerable<T2>> f) | |
{ | |
var result = new List<T2>(); | |
var coll = xs.GetEnumerator(); | |
while (coll.MoveNext()) | |
{ | |
var current = f(coll.Current); | |
foreach (var item in current) | |
{ | |
result.Add(item); | |
} | |
} | |
return result; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment