Advertisement
Guest User

Eric Lippert's challenge - cleanererer

a guest
Sep 10th, 2010
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1. sealed class Dumper
  2. {
  3.     static public string Dump(Node root)
  4.     {
  5.         return Dump( root, "" );
  6.     }
  7.     static private string Dump(Node node, string indent)
  8.     {
  9.         return node.Text + "\n" + node.Children.Take(node.Children.Count - 1)
  10.             .Aggregate(string.Empty,
  11.                 (results, child) => results + indent + "├─" + Dump(child, indent + "│ ") ) +
  12.             ( node.Children.Count == 0 ? "" : indent + "└─" + Dump(node.Children.Last(), indent + "  " ) );
  13.     }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement