Blog Logo
TAGS

Head and Tail using list patterns in C#

Some time ago I wrote blog posts playing with head- and tail-like functions and implementing sum function in C# using these. With the recent addition of list patterns into C# 11, I revisited that topic. In fact, the list pattern makes it very easy to implement. And also looks, in my opinion, most slick from all the previous. This article discusses implementing the sum function in C# using head and tail functions with list patterns. The article also discusses the challenges encountered while using List<T> as the datatype and provides a solution using a ListRangeWrapper<T> class. The article concludes with a mention of another new feature in C#11 - generic math - and promises a blog post on it. The author of the article, Jiří Činčura, is a .NET, C# and Firebird expert who works as a software engineer for Microsoft. He is a frequent speaker and blogger at www.tabsoverspaces.com.