data Book  = <book>(Title . Author*. Section*);
data Title = <title>(String);
data Author = <author>(String);
data Section = <section> (Title . T*);
data T = <p>(String) 
       | Section;


flatsec(<book>(x :: Title . y :: Author* . z :: Section*)) = <seclist>(h(z));
h($) = $;
h(<section>( t :: Title . v :: T*) . r :: Section* ) = <section>(t) . g(v) . h(r);
g($) = $;
g(<p>(x::String) . r :: T*) = g(r);
g(x :: Section . r :: T*) = h(x) . g(r);


