diff options
| author | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-08-21 08:24:32 -0500 |
|---|---|---|
| committer | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-08-21 09:56:06 -0500 |
| commit | 30e92c33303535a86e56824b668f46ad0c6261a8 (patch) | |
| tree | df037059d07f48d1bd4ad434bf81b6e6688a032a /radix_info.go | |
| parent | ff5bc533399cb7fc7b83afcc3a20e6abbc05d444 (diff) | |
Upgrade to Go 1.21
Use methods from the new slices and maps modules to make my code faster
and more compact.
Diffstat (limited to 'radix_info.go')
| -rw-r--r-- | radix_info.go | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/radix_info.go b/radix_info.go index 3e83aad..a107b73 100644 --- a/radix_info.go +++ b/radix_info.go @@ -4,7 +4,7 @@ import ( "aphopkins/radix_info/factors" "fmt" "os" - "sort" + "slices" "strconv" ) @@ -15,9 +15,7 @@ func main() { n := uint(n) fmt.Printf("%d = %s\n", n, factors.PrimeFactorize(n)) n_factors := factors.Factors(n) - sort.Slice(n_factors, func(i, j int) bool { - return n_factors[i] < n_factors[j] - }) + slices.Sort(n_factors) factorScore := factors.Score(n) fmt.Printf("Factors: %v (Score: %.2f)\n", n_factors, factorScore) fmt.Printf("Totative Ratio: %03.1f%%\n", |
