RosettaCodeData/Task/Create-an-HTML-table/Scheme/create-an-html-table.scm

22 lines
704 B
Scheme

(define table #(
#("" "X" "Y" "Z")
#(1 1 2 3)
#(2 4 5 6)
#(3 7 8 9)))
(display "<table>")
(do ((r 0 (+ r 1))) ((eq? r (vector-length table)))
(display "<tr>")
(do ((c 0 (+ c 1))) ((eq? c (vector-length (vector-ref table r))))
(if (eq? r 0)
(display "<th>"))
(if (> r 0)
(display "<td>"))
(display (vector-ref (vector-ref table r) c))
(if (eq? r 0)
(display "</th>"))
(if (> r 0)
(display "</td>")))
(display "</tr>"))
(display "</table>")