type wranging

This commit is contained in:
NunoSempere 2024-06-10 00:05:23 +02:00
parent b0adde937f
commit 8b1792f861

12
f.go
View File

@ -213,10 +213,11 @@ func prettyPrintLognormal(low float64, high float64) {
} }
func prettyPrintDist(dist Dist) { func prettyPrintDist(dist Dist) {
if dist.Type() == "Lognormal" { switch v := dist.(type) {
prettyPrintLognormal(dist.low, dist.high) case Lognormal:
} else { prettyPrintLognormal(v.low, v.high)
fmt.Printf("%v", dist) default:
fmt.Printf("%v", v)
} }
} }
@ -228,7 +229,8 @@ func main() {
fmt.Printf("%v\n", x) fmt.Printf("%v\n", x)
reader := bufio.NewReader(os.Stdin) 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 old_dist := init_dist
vars := make(map[string]Dist) vars := make(map[string]Dist)
// Could eventually be a more complex struct with: // Could eventually be a more complex struct with: