Create an HTML table.

 The table body should have at least three rows of three columns.
 Each of these three columns should be labelled "X", "Y", and "Z". 
 An extra column should be added at either the extreme left or the extreme right of the table that has no heading, but is filled with sequential row numbers. 
 The rows of the "X", "Y", and "Z" columns should be filled with random or sequential integers having 4 digits or less. 
 The numbers should be aligned in the same fashion for all columns.


(  ( makeTable
  =     headTexts
        minRowNr
        maxRowNr
        headCells
        cells
        rows
        Generator
        Table
    .   get$"xmlio.bra"             { A library that converts from Bracmat format to XML or HTML }
      & !arg:(?headTexts.?minRowNr.?maxRowNr.?Generator)
      & ( headCells
        =   cellText
          .     !arg:%?cellText ?arg
              & (th.,!cellText) headCells$!arg
            | 
        )
      & ( cells
        =   cellText cellTexts numberGenerator
          .       !arg
                : (%?cellText ?cellTexts.(=?numberGenerator))
              &   (td.,numberGenerator$)
                  cells$(!cellTexts.'$numberGenerator)
            | 
        )
      & ( rows
        =   headTexts rowNr maxRowNr Generator
          .     !arg:(?headTexts.?rowNr.?maxRowNr.?Generator)
              & !rowNr:~>!maxRowNr
              &   ( tr
                  .   
                    ,   (td.,!rowNr)
                        cells$(!headTexts.!Generator)
                  )
                  \n
                  rows$(!headTexts.!rowNr+1.!maxRowNr.!Generator)
            | 
        )
      &   ( table
          .   
            ,   ( thead
                .   (align.right)
                  , \n (tr.,(th.," ") headCells$!headTexts)
                )
                \n
                ( tbody
                .   (align.right)
                  ,   \n
                        rows
                      $ (!headTexts.!minRowNr.!maxRowNr.!Generator)
                )
          )
        : ?Table
      & str$((XMLIO.convert)$!Table)      { Call library function to create HTML }
  )
&   makeTable
  $ ( X Y Z                               { Column headers }
    . 1                                   { Lowest row number }
    . 4                                   { Highest row number }
    .                                     { Function that generates numbers 9, 10, ...}
      ' ( cnt
        .   (cnt=$(new$(==8)))            { This creates an object 'cnt' with scope as a local function variable that survives between calls. }
          & !(cnt.)+1:?(cnt.)
        )
    )
)