MCPcopy Index your code
hub / github.com/gonum/plot / addCommas

Function addCommas

gob/gob_test.go:141–156  ·  view source on GitHub ↗

AddCommas adds commas after every 3 characters from right to left. NOTE: This function is a quick hack, it doesn't work with decimal points, and may have a bunch of other problems.

(s string)

Source from the content-addressed store, hash-verified

139// NOTE: This function is a quick hack, it doesn't work with decimal
140// points, and may have a bunch of other problems.
141func addCommas(s string) string {
142 rev := ""
143 n := 0
144 for i := len(s) - 1; i >= 0; i-- {
145 rev += string(s[i])
146 n++
147 if n%3 == 0 {
148 rev += ","
149 }
150 }
151 s = ""
152 for i := len(rev) - 1; i >= 0; i-- {
153 s += string(rev[i])
154 }
155 return s
156}

Callers 1

TicksMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected