Documentation
¶
Overview ¶
Package algorithmic implements parsing and formatting of common non-decimal number systems, such as roman numerals and traditional tamil numbers.
These correspond to the rules in CLDR 41.0 at "rbnf/root.xml" (and does not include every algorithmic numbering system mentioned in "numberingSystems.xml").
Example (RulesetNames) ¶
package main import ( "fmt" "github.com/tawesoft/golib/v2/must" "github.com/tawesoft/golib/v2/text/number/algorithmic" ) func main() { const v = int64(1234) fmt.Printf("Supported rulesets and example(%d):\n", v) for _, name := range algorithmic.RulesetNames { str := must.Result(algorithmic.Format(name, v)) fmt.Printf("> %s; %s\n", name, str) } }
Output: Supported rulesets and example(1234): > armenian-lower; ռմլդ > armenian-upper; ՌՄԼԴ > cyrillic-lower; ҂асл҃д > ethiopic; ፩፻፪፻፴፬ > georgian; შსლდ > greek-lower; ͵ασλδ´ > greek-upper; ͵ΑΣΛΔ´ > hebrew; א׳רל״ד > hebrew-item; תתתלד > roman-lower; mccxxxiv > roman-upper; MCCXXXIV > tamil; ௲௨௱௩௰௪
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RulesetNames = func() []string { xs := group.RulesetNames() sort.Strings(xs) return xs }()
RulesetNames is a slice of all algorithmic rulesets implemented by this package.
Functions ¶
func Format ¶
Format formats a number using a given algorithmic ruleset such as "roman-upper".
Example ¶
package main import ( "fmt" "github.com/tawesoft/golib/v2/text/number/algorithmic" ) func main() { print := func(system string, n int64) { if s, err := algorithmic.Format(system, n); err == nil { fmt.Printf("algorithmic.Format(%q, %d): %q\n", system, n, s) } else { fmt.Printf("algorithmic.Format(%q, %d): error: %v\n", system, n, err) } } print("roman-upper", 2023) }
Output: algorithmic.Format("roman-upper", 2023): "MMXXIII"
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.