-
-
Save wannaphong/24bbc64c252391b972e2f582c0cff759 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