(* * val mkHtmlTable : ('a list * 'b list) -> ('a -> string * 'b -> string) * -> (('a * 'b) -> string) -> string * The int list is list of colums, the function returns the values * at a given colum and row. * returns the HTML code of the generated table. *) fun mkHtmlTable (columns, rows) (rowToStr, colToStr) values = let val text = ref "\n" in (* Add headers *) map (fn colum => text := !text ^ "") columns; text := !text ^ "\n"; (* Add data rows *) map (fn row => (* row name *) (text := !text ^ ""; (* data *) map (fn col => text := !text ^ "") columns; text := !text ^ "\n") ) rows; !text ^ "
" ^ (colToStr colum) ^ "
" ^ (rowToStr row) ^ "" ^ (values (row, col)) ^ "
" end fun mkHtmlWithBody (title, body) = "\n\n" ^ title ^ "\n\n\n" ^ body ^ "\n\n\n" fun samplePage () = mkHtmlWithBody ("Sample Page", mkHtmlTable ([1.0,2.0,3.0,4.0,5.0], [1.0,2.0,3.0,4.0]) (Real.toString, Real.toString) (fn (a, b) => Real.toString (Math.pow (a, b)))) val _ = print (samplePage ())