<bigwig> service: genealogy


service {
  html EnterDepth = <html>
    Please select the depth of the genealogical tree (0-9):
    <input type=text name="depth" size=1 maxlength=1>
  </html>;
  html GenealogyDoc = <html>
    <h1>Genealogical Tree</h1>
    <hr>
    For <[depth]> generation(s):
    <br>
    <b>You</b>
    <[your_tree]>
  </html>;
  html GenerationDoc = <html>
    <ul>
      <li><[mother]></li>
      <[mothers_tree]>
      <li><[father]></li>
      <[fathers_tree]>
    </ul>
  </html>;
  html genTree(int depth, string s) {
    if (depth <= 0) return <html></html>;
    else return GenerationDoc <[mother=s + "mother", 
        mothers_tree=genTree(depth - 1, s + "mother\'s "), 
        father=s + "father", 
        fathers_tree=genTree(depth - 1, s + "father\'s ")];
  }
  
  session GenTree() {
    int depth;
    
    show EnterDepth receive [depth=depth];
    if (depth > 9) exit <html>depth must be between 0 and 9</html>;
    exit GenealogyDoc <[depth=depth, your_tree=genTree(depth, "your ")];
  }
}