(define $xml (matcher {[,$val [] {[$tgt (match [val tgt] [xml xml] {[[ ] {[]}] [[ ] {[]}] [[_ _] {}]})]}] [ [string string] {[ {[tag text]}] [_ {}]}] [ [string (list xml)] ; Node whose children are seen as a list. {[ {[tag cs]}] [_ {}]}] [ [string (multiset xml)] ; Node whose children are seen as a multiset. {[ {[tag cs]}] [_ {}]}] [ xml {[$x {x @(all-descendants x)}]}] [$ [something] {[$tgt {tgt}]}] })) (define $all-descendants (lambda [$x] (match x xml {[ {}] [ {@cs @(concat (map all-descendants cs))}]})))