From 30e92c33303535a86e56824b668f46ad0c6261a8 Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Mon, 21 Aug 2023 08:24:32 -0500 Subject: Upgrade to Go 1.21 Use methods from the new slices and maps modules to make my code faster and more compact. --- radix_info.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'radix_info.go') 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", -- cgit v1.2.3