;;; ;;; ;;; Tree demonstration ;;; ;;; ;; ;; Matcher definition ;; (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 (match-all t (tree a b) [(loop $i [1 _] > $x) x])]}] [$ [something] {[$tgt {tgt}]}] }))) ;; ;; Demonstration code ;; (define $tree-data }> }> }> }> }> }> }>) ; All langauges (test (unique/m string (match-all tree-data (tree string string) [> x]))) ; All langauges that belongs to Functional language (test (unique/m string (match-all tree-data (tree string string) [> _>>> x]))) ; All langauges that belongs more than two categories (test (unique/m string (match-all tree-data (tree string string) [> > _>>> x]))) ; All categories that Egison belongs (test (match-all tree-data (tree string string) [(loop $i [1 $n] > ) c]))