Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static public string Dump(Node root)
- {
- return string.Join("",
- new[] { root.Text + "\n" }.Concat(
- root.Children.Take(root.Children.Count - 1).Select(Dump).Select(x => "├─" + x.TrimEnd().Replace("\n", "\n│ ")+"\n"))
- .Concat(root.Children.Skip(root.Children.Count - 1).Select(Dump).Select(x => "└─" + x.TrimEnd().Replace("\n", "\n ")+"\n"))
- .ToArray());
- }
- static public string Dump(Node root)
- {
- Func<Func<IEnumerable<Node>, int, IEnumerable<Node>>, string, string, Func<IEnumerable<Node>, IEnumerable<string>>> func =
- (take, a, b) => source => take(source, root.Children.Count - 1).Select(Dump)
- .Select(x => string.Format("{0}─{1}\n", a, x.TrimEnd().Replace("\n", "\n"+b+" ")));
- return string.Join("",
- new[] { root.
- Text + "\n" }.Concat(
- new []{func(Enumerable.Take,"├","│"),func(Enumerable.Skip,"└"," ")}.SelectMany(f => f(root.Children)))
- .ToArray());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement