use an array with a definite num of elements before adding concurrency

This commit is contained in:
NunoSempere 2024-02-25 19:03:25 -03:00
parent f85d128780
commit 1c8542bdc4

View File

@ -135,7 +135,8 @@ func main() {
var r = rand.New(rand.NewPCG(uint64(1), uint64(2))) var r = rand.New(rand.NewPCG(uint64(1), uint64(2)))
var dists []IntProbsWeights n_dists := 10_000
var dists = make([]IntProbsWeights, n_dists)
sum_weights := int64(0) sum_weights := int64(0)
for i := 0; i < 10_000; i++ { for i := 0; i < 10_000; i++ {
@ -149,7 +150,7 @@ func main() {
if result > 0 { if result > 0 {
// fmt.Println(people_known_distribution) // fmt.Println(people_known_distribution)
// fmt.Println(result) // fmt.Println(result)
dists = append(dists, IntProbsWeights{IntProbs: people_known_distribution, w: result}) dists[i] = IntProbsWeights{IntProbs: people_known_distribution, w: result}
} }
sum_weights += result sum_weights += result
// fmt.Println(result) // fmt.Println(result)