Skip to content

Latest commit

 

History

History
47 lines (35 loc) · 1.11 KB

README.md

File metadata and controls

47 lines (35 loc) · 1.11 KB

tinyield4net

Nuget

A Minimalistic, extensible and lazy sequence implementation for .Net .

Usage

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 => {
        T prev = 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 = new int[] { 7, 7, 8, 9, 9, 11, 11, 7 };
List<int> actual = Query.Of(arrange)
    .Then(n => Collapse(n))
    .Where(n => n % 2 != 0)
    .ToList();

Installation

$ dotnet add package com.tinyield.tinyield4net --version 1.0.0

Or check the nuget package for more info.

License

This project is licensed under Apache License, version 2.0