A Minimalistic, extensible and lazy sequence implementation for .Net .
An auxiliary Collapse() method, which merges series of adjacent elements is written with Tinyield in the following way:
Traverser<T>Collapse<T>(Query<T>src){return yld =>{Tprev=default(T);src.ForEach(item =>{if(prev.Equals(default(T))||!prev.Equals(item)){prev=item;yld(item);}});};}This method can be chained in a sequence like this:
int[]arrange=newint[]{7,7,8,9,9,11,11,7};List<int>actual=Query.Of(arrange).Then(n =>Collapse(n)).Where(n =>n%2!=0).ToList();$ dotnet add package com.tinyield.tinyield4net --version 1.0.0Or check the nuget package for more info.
This project is licensed under Apache License, version 2.0