diff options
| -rw-r--r-- | args.go | 4 | ||||
| -rw-r--r-- | factor_info.go | 9 | ||||
| -rw-r--r-- | radix_info.go | 2 |
3 files changed, 12 insertions, 3 deletions
@@ -13,6 +13,7 @@ const ProgramVersion = "1.0.0-alpha+dev" type args struct { Radix uint Compact bool + FullMap bool // If true, exit the program immediately after parsing args. Exit bool } @@ -20,6 +21,9 @@ type args struct { func parseArgs() (args, error) { var a args flag.BoolVar(&a.Compact, "c", false, "Compact the output display") + flag.BoolVar(&a.FullMap, "f", false, + fmt.Sprintf("Show full digit map (up to %d) for every radix", + maxSmallRadix)) help := flag.Bool("?", false, "Get information about program usage then exit") version := flag.Bool("V", false, diff --git a/factor_info.go b/factor_info.go index b6a4a3d..f908b9b 100644 --- a/factor_info.go +++ b/factor_info.go @@ -49,7 +49,7 @@ type FactorInfo struct { DigitMap []factors.DigitType } -func GetFactorInfo(radix uint) *FactorInfo { +func GetFactorInfo(radix uint, fullMap bool) *FactorInfo { r_factors := factors.Factors(radix) slices.Sort(r_factors) @@ -66,7 +66,12 @@ func GetFactorInfo(radix uint) *FactorInfo { } var digitMap []factors.DigitType - if radix <= maxSmallRadix { + if fullMap { + digitMap = make([]factors.DigitType, maxSmallRadix) + for d := 0; d < maxSmallRadix; d++ { + digitMap[d] = factors.GetDigitType(uint(d), radix) + } + } else if radix <= maxSmallRadix { digitMap = factors.DigitMap(radix) } else { digitMap = []factors.DigitType{} diff --git a/radix_info.go b/radix_info.go index fb1caef..0500a33 100644 --- a/radix_info.go +++ b/radix_info.go @@ -12,7 +12,7 @@ func main() { } if err == nil { - factorInfo := GetFactorInfo(args.Radix) + factorInfo := GetFactorInfo(args.Radix, args.FullMap) if args.Compact { factorInfo.WriteToCompact(os.Stdout) } else { |
