https://www.pexels.com/photo/computer-keyboard-34153/

Point Free or Die Hard

Having a look at the csharp lang github repo today, I came accross a question asking for the introduction of point free style syntax in Linq Operations. The example is available in the request

I have answered the question there, but am also just putting the code up here for myself. 

Here is an example of a c# point free And operations (if you really want it). Clearly, you can expand this out to other operations if you wanted to.

namespace Examples {
	static class Extensions{
		public static IEnumerable<T> PrintAll<T>(this IEnumerable<T> ts) {
			foreach (var t in ts) {
				Console.WriteLine(t);
				yield return t;
			}
		}
	}
	class Program {
		public static bool Foo(int x) => x % 2 == 0;
		public static bool Bar(int y) => y % 3 == 0;
		public static Func<T, bool> And<T>(Func<T, bool> f, Func<T, bool> g) => x => f(x) && g(x);
		public static Func<int, bool> FooAndBar => And<int>(Foo, Bar);
		static void Main()
			=>	Enumerable.Range(1, 20)
					   .Where(FooAndBar)
					   .PrintAll()
					   .ToList();

	}
}