Skip to content

Instantly share code, notes, and snippets.

@jm42
Created February 12, 2016 04:41
Show Gist options
  • Save jm42/ae6b7287826a13a04c13 to your computer and use it in GitHub Desktop.
Save jm42/ae6b7287826a13a04c13 to your computer and use it in GitHub Desktop.
BTree tagged union
<?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