Pretty-print number
This commit is contained in:
parent
63439ae06c
commit
7e312c6fa0
2
go.mod
2
go.mod
|
@ -1,3 +1,5 @@
|
|||
module git.kolaente.de/konrad/miracle-sort
|
||||
|
||||
go 1.12
|
||||
|
||||
require golang.org/x/text v0.3.0
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
7
main.go
7
main.go
|
@ -2,6 +2,9 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"golang.org/x/text/language"
|
||||
"golang.org/x/text/message"
|
||||
"golang.org/x/text/number"
|
||||
"sort"
|
||||
"time"
|
||||
)
|
||||
|
@ -25,6 +28,8 @@ func main() {
|
|||
var slice []int
|
||||
var sorted = false
|
||||
|
||||
p := message.NewPrinter(language.English)
|
||||
|
||||
for !sorted {
|
||||
// We put the map in a slice to have something more deterministic to work with
|
||||
slice = nil
|
||||
|
@ -41,7 +46,7 @@ func main() {
|
|||
}
|
||||
|
||||
iterations++
|
||||
fmt.Printf("\rIteration %d, no miracle happened yet.", iterations)
|
||||
p.Printf("\rIteration %v, no miracle happened yet.", number.Decimal(iterations))
|
||||
}
|
||||
|
||||
fmt.Println("\nSorted.")
|
||||
|
|
Loading…
Reference in New Issue