commit 8b1792f861925483c1e3c46da139302aa793302f
parent b0adde937f047c7f451996f9c2fddcd9b105776c
Author: NunoSempere <nuno.semperelh@protonmail.com>
Date: Mon, 10 Jun 2024 00:05:23 +0200
type wranging
Diffstat:
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/f.go b/f.go
@@ -213,10 +213,11 @@ func prettyPrintLognormal(low float64, high float64) {
}
func prettyPrintDist(dist Dist) {
- if dist.Type() == "Lognormal" {
- prettyPrintLognormal(dist.low, dist.high)
- } else {
- fmt.Printf("%v", dist)
+ switch v := dist.(type) {
+ case Lognormal:
+ prettyPrintLognormal(v.low, v.high)
+ default:
+ fmt.Printf("%v", v)
}
}
@@ -228,7 +229,8 @@ func main() {
fmt.Printf("%v\n", x)
reader := bufio.NewReader(os.Stdin)
- init_dist := Dist{Type: "Lognormal", Lognormal: Lognormal{low: 1, high: 1}, Samples: nil} // Could also just be a scalar
+ var init_dist Dist
+ init_dist = Lognormal{low: 1, high: 1}
old_dist := init_dist
vars := make(map[string]Dist)
// Could eventually be a more complex struct with: