Skip to content

Commit 9315d84

Browse files
committed
Remove the dist function; it is more efficient to compare squared distances
1 parent 3bd158c commit 9315d84

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/libstd/rand/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,6 @@
8989
//! use std::rand;
9090
//! use std::rand::distributions::{IndependentSample, Range};
9191
//!
92-
//! fn dist(x: f64, y: f64) -> f64 {
93-
//! (x*x + y*y).sqrt()
94-
//! }
95-
//!
9692
//! fn main() {
9793
//! let between = Range::new(-1f64, 1.);
9894
//! let mut rng = rand::task_rng();
@@ -103,7 +99,7 @@
10399
//! for _ in range(0u, total) {
104100
//! let a = between.ind_sample(&mut rng);
105101
//! let b = between.ind_sample(&mut rng);
106-
//! if dist(a, b) <= 1. {
102+
//! if a*a + b*b <= 1. {
107103
//! in_circle += 1;
108104
//! }
109105
//! }

0 commit comments

Comments
 (0)