我的目标是将我的表格打印得尽可能接近,每个列之间有均匀的空格。
(defn PrintTable [tableName]
"prints table in clear format"
(let [tableRef (get (deref dataBase) tableName) ; get refrence for table
keyList (keys @tableRef)] ; get key list of table
(doseq [tableKeys (range (count keyList))] ; print the keys of the table
(let [key (nth (keys @tableRef) tableKeys)]
(print key "\t|"))
)
(println)
(doseq [rows (range (count @(tableRef (nth (keys @tableRef) 0))))] ; print for each rows all the values
(doseq [cols (range (count keyList))]
(let [key (nth (keys @tableRef) cols)]
(print (@(tableRef key) rows) "\t|")
)
)
(println)
)
)
(println)
)
我试过使用标签,但这是我得到的结果:
P_Id |LastName |FirstName |Address |City |
1 |Darmon |Gilad |ishayahu |Haifa |
2 |SM |Shiran |erez |RamatIshay |
D_Id |Name |OwnerLastName |OwnerFirstName |
a |Bono |Darmon |Gilad |
b |Bony |SM |Shiran |
对更好和对齐的打印有什么建议吗?