- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1
 
Flattening
        Carl Smith edited this page May 30, 2018 
        ·
        1 revision
      
    Flattening is an important concept in Stan. HTME automatically flattens structures when they are assigned, so you never really give it much thought.
Anywhere you can pass a child to a constructor or operator, you can alternatively pass a sequence of children, which can be nested arbitrarily. For example, the following two statements are equivalent:
docs *= P, P, P, P, P, P, P
docs *= [P, P], P, (P, (P, P)), P, []These two statements are also equivalent:
DIV(P, P, P, P, P, P, P)
DIV([P, P], P, (P, (P, P)), P, [])By default, the flattening function (flatten) treats any instance of tuple or list (or any subclass, including Nodes) as non-terminal, and everything else (including strings) as terminal.
HTME | The Hypertext Markup Engine | Simple, Pythonic HTML Code Generation for Python 2 or 3
To learn to use HTME, read these articles (in this order):