Exemplo n.º 1
0
        static object _Read(GridNode node)
        {
            var groups = node.Head
                         .Select((v, y) => (y: y + 1, v))
                         .Where(t => t.v != "")
                         .GroupBy(t => t.v)
                         .Select(g => SimpleGroup.From(g.Select(t => t.y), Sym.From(g.Key)))
                         .ToArray();

            var map = groups.Aggregate(
                Map <int, Sym> .Empty,
                (m, g) => m.Add(GroupMap.Lift(g.Nodes, g.Value)));

            if (node.Tail != null)
            {
                var right = Read(node.Tail).As <Map <int, Sym> >();
                map = map.Add(right);
            }

            return(map);
        }
Exemplo n.º 2
0
 public static SimpleGroup <int, Sym> Simple(this Group <int, Sym> group)
 => SimpleGroup.From(group.Nodes, group.Value);