Functional Extensions for C#

No Comments

Map

public static TResult Map<TSource, TResult>(
	this TSource @this,
	Func<TSource, TResult> fn) => fn(@this);
);

Tee

public static TResult Tee<t>(
	this T @this,
	Action<T> fn) => fn(@this)
    {
		act(@this);
		return @this;
	}
);

Partial Function Application

public static Func<int, int> Add(int x) => y => x + y;
new[] {1, 2, 3}.Select(Add(1))

More stuff like this in Dave Fancher PluralSight course Functional Programming with C#

Categories: C#

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Loading Facebook Comments ...