Category talk:Go-rcu: Difference between revisions

Content added Content deleted
(Added source code for new 'Go-rcu' package.)
 
(→‎Source code: Added commatize option to PrintTable function.)
Line 161: Line 161:


// Prints a slice of ints in tabular form with a given row and column size.
// Prints a slice of ints in tabular form with a given row and column size.
func PrintTable(s []int, rowSize, colSize int) {
func PrintTable(s []int, rowSize, colSize int, commas bool) {
for i := 0; i < len(s); i++ {
for i := 0; i < len(s); i++ {
fmt.Printf("%*d ", colSize, s[i])
if !commas {
fmt.Printf("%*d ", colSize, s[i])
} else {
fmt.Printf("%*s ", colSize, Commatize(s[i]))
}
if (i+1)%rowSize == 0 {
if (i+1)%rowSize == 0 {
fmt.Println()
fmt.Println()