Created
February 12, 2016 04:41
-
-
Save jm42/ae6b7287826a13a04c13 to your computer and use it in GitHub Desktop.
BTree tagged union
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
| <?php | |
| abstract class Tree {} | |
| class Leaf extends Tree { | |
| function __construct($n) { | |
| $this->value = $n; | |
| } | |
| } | |
| class Node extends Tree { | |
| function __construct($n, Tree $left, Tree $right) { | |
| $this->value = $n; | |
| $this->left = $left; | |
| $this->right = $right; | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment