Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func demoSimplePrintTable() {
- let rowLabels = [
- "row 1",
- "row 2",
- "row 3 looooong"
- ]
- let columnLabels = [
- "column 1 loooong",
- "column 2",
- "column 3"
- ]
- let data = [
- [100, 20, 30],
- [1, 5, 10],
- [1000, 4, 200000000]
- ]
- printTable(rl : rowLabels, cl : columnLabels, data : data)
- }
- func printTable(rl : [String], cl : [String], data : [[Int]]) {
- for (i, clabel) in cl.enumerated(){
- if i < 1 {
- print("rien | ", terminator:"")
- }
- print (clabel + " | ", terminator:"")
- }
- print("")
- for (j,rlabel) in rl.enumerated() {
- print(rlabel, terminator:" | ");
- for x in data[j] {
- print(x, terminator:" | ")
- }
- print("")
- }
- }
- demoSimplePrintTable()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement