(define $b-tree (lambda [$a $b] (algebraic-data-matcher { }))) (define $tree (lambda [$a $b] (matcher {[,$val [] {[$tgt (match [val tgt] [(tree a b) (tree a b)] {[[ ] {[]}] [[_ _] {}]})]}] [ b {[ {x}] [_ {}]}] [ [a (list (tree a b))] ; Node whose children are seen as a list. {[ {[x ts]}] [_ {}]}] [ [a (multiset (tree a b))] ; Node whose children are seen as a multiset. {[ {[x ts]}] [_ {}]}] [ [(tree a b)] {[$t {t @(match-all t (tree a b) [ _>> x])}]}] [$ [something] {[$tgt {tgt}]}] })))