Skip to content

Instantly share code, notes, and snippets.

@dcolish
Created June 30, 2013 20:57
Show Gist options
  • Save dcolish/5896851 to your computer and use it in GitHub Desktop.
Save dcolish/5896851 to your computer and use it in GitHub Desktop.
bloom.rs:6:0: 6:10 error: `use` and `extern mod` declarations must precede items
bloom.rs:6 use mumur;
^~~~~~~~~~
bloom.rs:7:0: 7:8 error: `use` and `extern mod` declarations must precede items
bloom.rs:7 use fnv;
^~~~~~~~
bloom.rs:8:0: 8:16 error: `use` and `extern mod` declarations must precede items
bloom.rs:8 use extra::bitv;
^~~~~~~~~~~~~~~~
bloom.rs:10:0: 10:13 error: `use` and `extern mod` declarations must precede items
bloom.rs:10 use std::f64;
^~~~~~~~~~~~~
bloom.rs:11:0: 11:20 error: `use` and `extern mod` declarations must precede items
bloom.rs:11 use std::num::{log};
omega:rust-bloom (101) $ tree -P "*.rs"
.
├── bloom.rs
├── fnv.rs
├── hash.rs
├── lib.rs
└── murmur.rs
extern mod extra;
pub mod murmur;
pub mod fnv;
use mumur;
use fnv;
use extra::bitv;
use std::f64;
use std::num::{log};
fn main () {
let v = optimalNumBits(1000, 1.0);
println(fmt!("%?", v));
}
/**
*/
fn optimalNumBits(n: u64, p: float) -> u64 {
// TODO: assert 0 < p < 1
_p = match p {
0.0 => f64::min_value,
_ => p
};
( -n * log(p) / (log(2) * log(2))) as u64
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment