C#C
C#2y ago
Moods

Convert to LINQ

How would y'all make this using just LINQ functions?
IEnumerable<string[]> SequenceOfGrids(string[] input)
{
    var res = new List<string[]>();
    
    int start = 0;
    
    for(int a = 1; a < input.Length; a++)
    {
        if(string.IsNullOrWhiteSpace(input[a]))
        {
            res.Add(input[start..a]);
            start = a + 1;
        }
    }
    
    res.Add(input[start..^0]);
    
    return res;
}

basically input is a collection of grids separated by one whitespace line, and i want to transform it into a list of the grids

here is a cutout of an example of such a grid

123
456
789

123
456
789
Was this page helpful?