Documentation
¶
Index ¶
- Constants
- func Atof(str string) float64
- func Atoi(str string) int
- func CleanFilename(filename string) string
- func CloseFile(file *os.File)
- func CreateFile(filename string) *os.File
- func GetLogger(programName string) *logging.Logger
- func GetSortedKey(m map[string]int, increase bool) []string
- func IsDir(dir string) bool
- func Levenshtein(str1, str2 string, costIns, costRep, costDel int) int
- func Logger(preMsg string, variable interface{})
- func MaxInt(a, b int) int
- func MonteCarlo(f func([]float64) float64, d Distribution, samples, dim int, ch chan<- float64)
- func OpenFile(filename string) *os.File
- func PadZero(number int, digitLength int, padChar string) (numberStr string)
- func PageBreak(msg ...interface{})
- func ParallelMonteCarlo(f func([]float64) float64, d Distribution, samples, dim int) float64
- func PrintVar(debuging bool, varName string, varValue ...interface{})
- func RandomDNA(length int) string
- func RandomInt(maximum int) int
- func RandomIntSlice(length int, minimum int, maximum int) []int
- func RandomSentence(wordNum int) string
- func RandomString(length int) string
- func ReadCSVTable(file string, seperator string) map[string]string
- func ReadLines(file string) []string
- func ReverseString(s string) string
- func ReverseStringSlice(s []string)
- func SimilarText(first, second string, percent *float64) int
- func WriteFile(file *os.File, content string)
- func WriteLines(filename string, lines []string)
- type Distribution
- type MapStringFloat
- type MapStringInt
- type Normal
- type PairStringFloatSlice
- type PairStringIntSlice
- type Uniform
Constants ¶
const ( // RedText start a red text output in fmt.Print RedText = "\x1b[1m\x1b[31m" // GreenText start a green text output in fmt.Print GreenText = "\x1b[1m\x1b[32m" // YellowText start a yellow text output in fmt.Print YellowText = "\x1b[1m\x1b[33m" // BlueText start a blue text output in fmt.Print BlueText = "\x1b[1m\x1b[34m" // MagentaText start a blue text output in fmt.Print MagentaText = "\x1b[1m\x1b[35m" // CyanText start a blue text output in fmt.Print CyanText = "\x1b[1m\x1b[36m" // ColorEnd end all color output in fmt.Print ColorEnd = "\x1b[0m" )
const Version = "v0.1.0"
Version of xlib
Variables ¶
This section is empty.
Functions ¶
func CleanFilename ¶
CleanFilename get rid of misc characters, only leave letter, number, '.' and '_'
func CreateFile ¶
CreateFile create file for write and check errors
func GetLogger ¶
func GetLogger(programName string) *logging.Logger
GetLogger returns a Logger of go-logging package
func GetSortedKey ¶
GetSortedKey do reversing of the string slice
func Levenshtein ¶
Levenshtein calculate costIns: Defines the cost of insertion. costRep: Defines the cost of replacement. costDel: Defines the cost of deletion.
func MonteCarlo ¶
func MonteCarlo(f func([]float64) float64, d Distribution, samples, dim int, ch chan<- float64)
MonteCarlo estimates the expected value of f under the distribution d using given number of samples. Note that f is of function type.
func ParallelMonteCarlo ¶
func ParallelMonteCarlo(f func([]float64) float64, d Distribution, samples, dim int) float64
ParallelMonteCarlo are ..
func RandomIntSlice ¶
RandomIntSlice generate slice of random Int [minimum, maximum]
func RandomSentence ¶
RandomSentence produce string of char of ascii 32 ~ 126
func RandomString ¶
RandomString produce string of char of ascii 32 ~ 126
func ReadCSVTable ¶
ReadCSVTable read csv file int map[id:string]line:string
func ReverseStringSlice ¶
func ReverseStringSlice(s []string)
ReverseStringSlice do reversing of string slice
func SimilarText ¶
SimilarText find similarity
func WriteLines ¶
WriteLines write slice of string into file
Types ¶
type Distribution ¶
type Distribution interface {
Rand() float64
}
Distribution interface define random number generation
type MapStringFloat ¶
MapStringFloat for sort map[string]int
func (*MapStringFloat) Sort ¶
func (m *MapStringFloat) Sort(ascend bool) PairStringFloatSlice
Sort method of MapStringFloat
type MapStringInt ¶
MapStringInt for sort map[string]int
func (MapStringInt) Sort ¶
func (m MapStringInt) Sort(ascend bool) PairStringIntSlice
Sort method of MapStringInt
type PairStringFloatSlice ¶
type PairStringFloatSlice []pairStringFloat
PairStringFloatSlice is []struct{string,float64}
func (PairStringFloatSlice) Len ¶
func (p PairStringFloatSlice) Len() int
func (PairStringFloatSlice) Less ¶
func (p PairStringFloatSlice) Less(i, j int) bool
func (PairStringFloatSlice) Swap ¶
func (p PairStringFloatSlice) Swap(i, j int)
type PairStringIntSlice ¶
type PairStringIntSlice []pairStringInt
PairStringIntSlice is []struct{string, int}
func (PairStringIntSlice) Len ¶
func (p PairStringIntSlice) Len() int
func (PairStringIntSlice) Less ¶
func (p PairStringIntSlice) Less(i, j int) bool
func (PairStringIntSlice) Swap ¶
func (p PairStringIntSlice) Swap(i, j int)