Sha256: b578dd1225eb3521125081d6b668b78899e04e173231dffe6138f22844723acd

Contents?: true

Size: 569 Bytes

Versions: 263

Compression:

Stored size: 569 Bytes

Contents

using System.Collections;

public static class Flattener
{
    public static IEnumerable Flatten(IEnumerable input)
    {
        foreach (var element in input)
        {
            var enumerable = element as IEnumerable;
            if (enumerable != null)
            {
                foreach (var flattenedElement in Flatten(enumerable))
                {
                    yield return flattenedElement;
                }
            }
            else if (element != null)
            {
                yield return element;
            }
        }
    }
}

Version data entries

263 entries across 263 versions & 1 rubygems

Version Path
trackler-2.2.1.45 tracks/csharp/exercises/flatten-array/Example.cs
trackler-2.2.1.44 tracks/csharp/exercises/flatten-array/Example.cs
trackler-2.2.1.43 tracks/csharp/exercises/flatten-array/Example.cs
trackler-2.2.1.42 tracks/csharp/exercises/flatten-array/Example.cs
trackler-2.2.1.41 tracks/csharp/exercises/flatten-array/Example.cs
trackler-2.2.1.40 tracks/csharp/exercises/flatten-array/Example.cs
trackler-2.2.1.39 tracks/csharp/exercises/flatten-array/Example.cs
trackler-2.2.1.38 tracks/csharp/exercises/flatten-array/Example.cs
trackler-2.2.1.37 tracks/csharp/exercises/flatten-array/Example.cs
trackler-2.2.1.36 tracks/csharp/exercises/flatten-array/Example.cs
trackler-2.2.1.35 tracks/csharp/exercises/flatten-array/Example.cs
trackler-2.2.1.34 tracks/csharp/exercises/flatten-array/Example.cs
trackler-2.2.1.33 tracks/csharp/exercises/flatten-array/Example.cs
trackler-2.2.1.32 tracks/csharp/exercises/flatten-array/Example.cs
trackler-2.2.1.31 tracks/csharp/exercises/flatten-array/Example.cs
trackler-2.2.1.30 tracks/csharp/exercises/flatten-array/Example.cs
trackler-2.2.1.29 tracks/csharp/exercises/flatten-array/Example.cs
trackler-2.2.1.28 tracks/csharp/exercises/flatten-array/Example.cs
trackler-2.2.1.27 tracks/csharp/exercises/flatten-array/Example.cs
trackler-2.2.1.26 tracks/csharp/exercises/flatten-array/Example.cs