
Eric Lippert's challenge - cleanererer
By: a guest on
Sep 10th, 2010 | syntax:
C# | size: 0.51 KB | hits: 43 | expires: Never
sealed class Dumper
{
static public string Dump(Node root)
{
return Dump( root, "" );
}
static private string Dump(Node node, string indent)
{
return node.Text + "\n" + node.Children.Take(node.Children.Count - 1)
.Aggregate(string.Empty,
(results, child) => results + indent + "├─" + Dump(child, indent + "│ ") ) +
( node.Children.Count == 0 ? "" : indent + "└─" + Dump(node.Children.Last(), indent + " " ) );
}
}