-
-
Save dimitris-papadimitriou-chr/6b1d1b6d3a88f49d9cc1ba1cd6722397 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static partial class FunctionalExt | |
{ | |
public static Tree<T> Reverse<T>(this Tree<T> @this) => | |
@this switch | |
{ | |
Leaf<T> { Value: var v } => new Leaf<T>(v), | |
Node<T> { Left: var l, Value: var v, Right: var r } => | |
new Node<T>(r.Reverse(), v, l.Reverse()), | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment