Created
July 18, 2012 00:23
-
-
Save huangcd/3133167 to your computer and use it in GitHub Desktop.
a map function like python in C#
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
public static IEnumerable<TResult> Map<in TSource, TResult>(IEnumerable<TSource> sources, Func<TSource, TResult> mapper) | |
{ | |
foreach (var source in sources) | |
{ | |
yield return mapper(source); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment