public static IEnumerable Traverse(this T root, Func> getChildren) { return Enumerable.Repeat(root, 1) .Concat((getChildren(root) ?? Enumerable.Empty()) .SelectMany(child => Traverse(child, getChildren))); }
Post a Comment
No comments:
Post a Comment