RosettaCodeData/Task/Create-an-HTML-table/Rascal/create-an-html-table-1.rascal

19 lines
638 B
Plaintext

import IO;
import util::Math;
str html(str title, str content) = item("html", item("title", title) + item("body", content));
str item(str op, str content) = "\<<op>\><content>\</<op>\>";
str table(str content) = item("table border=\"0\"", content);
str tr(str content) = item("tr", content);
str td(str content) = item("td", content);
public str generateTable(int rows){
int i(){return arbInt(10000);};
rows = (tr(td("")+td("X")+td("Y")+td("Z"))
| it + tr(td("<x>")+td("<i()>")+td("<i()>")+td("<i()>"))
| x <- [1..rows]);
writeFile(|file:///location|,
html("Rosetta Code Table", table(rows)));
return "written";
}