Skip to content

Instantly share code, notes, and snippets.

@wannaphong
Forked from huangcd/map.cs
Created January 22, 2017 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wannaphong/24bbc64c252391b972e2f582c0cff759 to your computer and use it in GitHub Desktop.
Save wannaphong/24bbc64c252391b972e2f582c0cff759 to your computer and use it in GitHub Desktop.
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