RosettaCodeData/Task/Create-an-HTML-table/Bracmat/create-an-html-table.bracmat

67 lines
2.1 KiB
Plaintext

( ( 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.)
)
)
)