Ask Your Question

Revision history [back]

Here's an example of how to use LanguageExt to filter the first item in a list using C#:

var list = List(1,2,3,4,5);

var firstItem = list.Filter(x => x < 3) // filter for values less than 3
                     .Head(); // get the first element of the resulting list

Console.WriteLine(firstItem); // output: 1

In this example, we start with a list of integers and use the List constructor from LanguageExt to create the list variable. We then use the Filter method to filter for elements with a value less than 3, which gives us a new List<int> with the values {1,2}. Finally, we use the Head method to extract the first element of that list, which is 1.