我的目标是将每张表格之间的间距均匀地打印出来。从Clojure中的DataBase打印表格
(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 |
任何建议,为一个更好的和一致的打印?
参见http://clojuredocs.org/clojure_core/clojure.pprint/print-table。 – 2013-02-22 19:49:53