From 6112c843654ac18812e3ff4f52a7235c4a664bf1 Mon Sep 17 00:00:00 2001 From: TheIronBorn Date: Thu, 7 Jul 2022 18:58:36 +0000 Subject: [PATCH 1/3] small deterministic example update --- examples/rayon-monte-carlo.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/rayon-monte-carlo.rs b/examples/rayon-monte-carlo.rs index 041f7379c48..9b47896aaa0 100755 --- a/examples/rayon-monte-carlo.rs +++ b/examples/rayon-monte-carlo.rs @@ -55,7 +55,7 @@ fn main() { .into_par_iter() .map(|i| { let mut rng = ChaCha8Rng::seed_from_u64(SEED); - // We chose ChaCha because it's fast, has suitable statical properties for simulation, + // We chose ChaCha because it's fast, has suitable statistical properties for simulation, // and because it supports this set_stream() api, which lets us chose a different stream // per work item. ChaCha supports 2^64 independent streams. rng.set_stream(i); @@ -69,7 +69,7 @@ fn main() { } count }) - .reduce(|| 0usize, |a, b| a + b); + .sum::(); // prints something close to 3.14159... println!( From 1f99bb72dcfebe7a8fc190bb344fff01092b1384 Mon Sep 17 00:00:00 2001 From: TheIronBorn Date: Fri, 8 Jul 2022 19:36:21 +0000 Subject: [PATCH 2/3] assert deterministic --- examples/rayon-monte-carlo.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/rayon-monte-carlo.rs b/examples/rayon-monte-carlo.rs index 9b47896aaa0..82d5a36ce62 100755 --- a/examples/rayon-monte-carlo.rs +++ b/examples/rayon-monte-carlo.rs @@ -71,6 +71,9 @@ fn main() { }) .sum::(); + // assert this is deterministic + assert_eq!(in_circle, 7852263); + // prints something close to 3.14159... println!( "π is approximately {}", From 89d7e4e184f920d2e34a133318e067f42a9eaff8 Mon Sep 17 00:00:00 2001 From: TheIronBorn Date: Sat, 9 Jul 2022 03:26:38 +0000 Subject: [PATCH 3/3] another typo --- examples/rayon-monte-carlo.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/rayon-monte-carlo.rs b/examples/rayon-monte-carlo.rs index 82d5a36ce62..f0e7114a657 100755 --- a/examples/rayon-monte-carlo.rs +++ b/examples/rayon-monte-carlo.rs @@ -56,7 +56,7 @@ fn main() { .map(|i| { let mut rng = ChaCha8Rng::seed_from_u64(SEED); // We chose ChaCha because it's fast, has suitable statistical properties for simulation, - // and because it supports this set_stream() api, which lets us chose a different stream + // and because it supports this set_stream() api, which lets us choose a different stream // per work item. ChaCha supports 2^64 independent streams. rng.set_stream(i); let mut count = 0;