1.1 Trees and lists

A sequence of matching brackets is called a list, if a pair of brackets enclose all other brackets. A list like

can be blown up to a bush and the bush can be dehydrated to a tree

     ()      ()()   
                    
  ()(  )()  (    )  
                    
 (        )(      ) 
                    
(                  )
       O   O O      
       |   \ /      
     O O O  O       
      \|/   |       
       O    O       
        \  /        
         O          
((()(())())((()())))

It's obvious that you can turn a tree into a list, going backwards.


1.2 A list of trees

 O
()
1: [,]
 O
 |
 O
(())
2: [1,1]
 O O
 \ /
  O 
(()())
3: [1,2]
 O
 |
 O
 |
 O
((()))
4: [2,1]
 O O O
  \|/ 
   O  
(()()())
5: [1,3]
   O
   |
 O O
 \ /
  O 
(()(()))
6: [1,4]
 O O
 \ /
  O 
  | 
  O 
((()()))
7: [3,1]
 O
 |
 O
 |
 O
 |
 O
(((())))
8: [4,1]

 O O O O
  \\ // 
    O   
(()()()())
9: [1,5]
     O
     |
 O O O
  \|/ 
   O  
(()()(()))
10: [1,6]
   O O
   \ /
 O  O 
  \ / 
   O  
(()(()()))
11: [1,7]
   O
   |
   O
   |
 O O
 \ /
  O 
(()((())))
12: [1,8]
 O O
 | |
 O O
 \ /
  O 
((())(()))
13: [2,4]
 O O O
  \|/ 
   O  
   |  
   O  
((()()()))
14: [5,1]
   O
   |
 O O
 \ /
  O 
  | 
  O 
((()(())))
15: [6,1]
 O O
 \ /
  O 
  | 
  O 
  | 
  O 
(((()())))
16: [7,1]
 O
 |
 O
 |
 O
 |
 O
 |
 O
((((()))))
17: [8,1]

Ok, trees!