get mvp of new parser!
This commit is contained in:
parent
29ea338112
commit
3bb705d13d
50
f2.go
50
f2.go
|
@ -106,16 +106,61 @@ func joinDists(old_dist Dist, new_dist Dist, op string) (Dist, error) {
|
||||||
low, high := multiplyLogBounds(old_dist.Lognormal.low, old_dist.Lognormal.high, new_dist.Lognormal.low, new_dist.Lognormal.high)
|
low, high := multiplyLogBounds(old_dist.Lognormal.low, old_dist.Lognormal.high, new_dist.Lognormal.low, new_dist.Lognormal.high)
|
||||||
return Dist{Type: "Lognormal", Lognormal: Lognormal{low: low, high: high}, Samples: nil}, nil
|
return Dist{Type: "Lognormal", Lognormal: Lognormal{low: low, high: high}, Samples: nil}, nil
|
||||||
default:
|
default:
|
||||||
fmt.Printf("For now, can't do anything besides multiplying lognormals")
|
fmt.Printf("For now, can't do anything besides multiplying lognormals\n")
|
||||||
}
|
}
|
||||||
return old_dist, errors.New("Error blah blah")
|
return old_dist, errors.New("Error blah blah")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Pretty print distributions */
|
||||||
|
func prettyPrintLognormal(low float64, high float64) {
|
||||||
|
// fmt.Printf("=> %.1f %.1f\n", low, high)
|
||||||
|
fmt.Printf("=> ")
|
||||||
|
switch {
|
||||||
|
case math.Abs(low) >= 1_000_000_000_000:
|
||||||
|
fmt.Printf("%.1fT", low/1_000_000_000_000)
|
||||||
|
case math.Abs(low) >= 1_000_000_000:
|
||||||
|
fmt.Printf("%.1fB", low/1_000_000_000)
|
||||||
|
case math.Abs(low) >= 1_000_000:
|
||||||
|
fmt.Printf("%.1fM", low/1_000_000)
|
||||||
|
case math.Abs(low) >= 1_000:
|
||||||
|
fmt.Printf("%.1fK", low/1_000)
|
||||||
|
case math.Abs(low) >= 1_000:
|
||||||
|
fmt.Printf("%.1fK", low/1_000)
|
||||||
|
default:
|
||||||
|
fmt.Printf("%.1f", low)
|
||||||
|
}
|
||||||
|
fmt.Printf(" ")
|
||||||
|
switch {
|
||||||
|
case math.Abs(high) >= 1_000_000_000_000:
|
||||||
|
fmt.Printf("%.1fT", high/1_000_000_000_000)
|
||||||
|
case math.Abs(high) >= 1_000_000_000:
|
||||||
|
fmt.Printf("%.1fB", high/1_000_000_000)
|
||||||
|
case math.Abs(high) >= 1_000_000:
|
||||||
|
fmt.Printf("%.1fM", high/1_000_000)
|
||||||
|
case math.Abs(high) >= 1_000:
|
||||||
|
fmt.Printf("%.1fK", high/1_000)
|
||||||
|
case math.Abs(high) >= 1_000:
|
||||||
|
fmt.Printf("%.1fK", high/1_000)
|
||||||
|
default:
|
||||||
|
fmt.Printf("%.1f", high)
|
||||||
|
}
|
||||||
|
fmt.Printf("\n")
|
||||||
|
// fmt.Printf("=> %.1f %.1f\n", low, high)
|
||||||
|
}
|
||||||
|
|
||||||
|
func prettyPrintDist(dist Dist) {
|
||||||
|
if dist.Type == "Lognormal" {
|
||||||
|
prettyPrintLognormal(dist.Lognormal.low, dist.Lognormal.high)
|
||||||
|
} else {
|
||||||
|
fmt.Printf("%v", dist)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Main event loop */
|
/* Main event loop */
|
||||||
func main() {
|
func main() {
|
||||||
reader := bufio.NewReader(os.Stdin)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
old_dist := Dist{Type: "Lognormal", Lognormal: Lognormal{low: 1, high: 1}, Samples: nil} // Could also just be a scalar
|
old_dist := Dist{Type: "Lognormal", Lognormal: Lognormal{low: 1, high: 1}, Samples: nil} // Could also just be a scalar
|
||||||
fmt.Printf("Hello world")
|
// fmt.Printf("Hello world")
|
||||||
|
|
||||||
EventForLoop:
|
EventForLoop:
|
||||||
for {
|
for {
|
||||||
|
@ -133,5 +178,6 @@ EventForLoop:
|
||||||
|
|
||||||
}
|
}
|
||||||
old_dist = joint_dist
|
old_dist = joint_dist
|
||||||
|
prettyPrintDist(old_dist)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user