Documentation ¶
Overview ¶
Example ¶
encoded, _ := Encode(5000) decoded, _ := Decode(encoded) fmt.Printf("5000 -> %v -> %d", encoded, decoded)
Output: 5000 -> [rub fog] -> 5000
Example (Fixed_range) ¶
encoded, _ := Encode(5000, 0, 10_000_000_000) decoded, _ := Decode(encoded, 0) fmt.Printf("5000 -> %v -> %d", encoded, decoded)
Output: 5000 -> [cannon cannon rub fog] -> 5000
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var List = []string{}/* 1024 elements not displayed */
List is the list of words used to encode values
Functions ¶
Types ¶
type Coder ¶
type Coder struct {
// contains filtered or unexported fields
}
Example ¶
coder, _ := New(0, 10_000_000) encoded, _ := coder.Encode(42) decoded, _ := coder.Decode(encoded) fmt.Printf("42 -> %v -> %d", encoded, decoded)
Output: 42 -> [cannon cannon tank] -> 42
func New ¶
New creates a new Coder. If passed two values, minimum and maximum, it will create slices of strings of a fixed length, adequate to encode all integers in that range. If passed a single value, minimum, it will create slices of strings of variable length, able to encode any number greater than or equal to minimum. If called with no parameters it creates a Coder that encodes any non-negative integer into a variable length slice of strings.
Click to show internal directories.
Click to hide internal directories.