Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
a map function like python in C#
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