Pretty-print number

This commit is contained in:
konrad 2019-04-07 14:19:46 +02:00
parent 63439ae06c
commit 7e312c6fa0
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
3 changed files with 10 additions and 1 deletions

2
go.mod
View File

@ -1,3 +1,5 @@
module git.kolaente.de/konrad/miracle-sort
go 1.12
require golang.org/x/text v0.3.0

2
go.sum Normal file
View File

@ -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=

View File

@ -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.")