starting adding interfaces + use go mod to allow for imports
This commit is contained in:
parent
313b744100
commit
3f0bcf0e03
22
f.go
22
f.go
|
@ -11,7 +11,23 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const NORMAL90CONFIDENCE = 1.6448536269514727
|
const NORMAL90CONFIDENCE = 1.6448536269514727
|
||||||
const general_err_msg = "Valid inputs: 2 || * 2 || / 2 || 2 20 || * 2 20 || / 2 20 || clean || =: var || op var || clean || help || debug || exit"
|
const GENERAL_ERR_MSG = "Valid inputs: 2 || * 2 || / 2 || 2 20 || * 2 20 || / 2 20 || clean || =: var || op var || clean || help || debug || exit"
|
||||||
|
|
||||||
|
// Distribution interface
|
||||||
|
// https://go.dev/tour/methods/9
|
||||||
|
|
||||||
|
type Distribution interface {
|
||||||
|
Samples() []float64
|
||||||
|
}
|
||||||
|
|
||||||
|
type Lognormal struct {
|
||||||
|
low float64
|
||||||
|
high float64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l Lognormal) Samples() []float64 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Actually, I should look up how do do a) enums in go, b) union types
|
// Actually, I should look up how do do a) enums in go, b) union types
|
||||||
type Lognormal struct {
|
type Lognormal struct {
|
||||||
|
@ -27,7 +43,7 @@ type Dist struct {
|
||||||
|
|
||||||
// Parse line into Distribution
|
// Parse line into Distribution
|
||||||
func parseLineErr(err_msg string) (string, Dist, error) {
|
func parseLineErr(err_msg string) (string, Dist, error) {
|
||||||
fmt.Println(general_err_msg)
|
fmt.Println(GENERAL_ERR_MSG)
|
||||||
fmt.Println(err_msg)
|
fmt.Println(err_msg)
|
||||||
return "", Dist{}, errors.New(err_msg)
|
return "", Dist{}, errors.New(err_msg)
|
||||||
}
|
}
|
||||||
|
@ -179,7 +195,7 @@ EventForLoop:
|
||||||
case words[0] == "exit" || words[0] == "e":
|
case words[0] == "exit" || words[0] == "e":
|
||||||
break EventForLoop
|
break EventForLoop
|
||||||
case words[0] == "help" || words[0] == "h":
|
case words[0] == "help" || words[0] == "h":
|
||||||
fmt.Println(general_err_msg)
|
fmt.Println(GENERAL_ERR_MSG)
|
||||||
continue EventForLoop
|
continue EventForLoop
|
||||||
case words[0] == "debug" || words[0] == "d":
|
case words[0] == "debug" || words[0] == "d":
|
||||||
fmt.Printf("Old dist: %v\n", old_dist)
|
fmt.Printf("Old dist: %v\n", old_dist)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user