const DEBUG: bool = false;
fn winnow(mut list: Vec<String>) -> (Conf, Vec<String> ) {
+
list.retain(|x| x != ""); // only keep nonempty
// Search patterns
},
};
+ if DEBUG {
+ eprintln!("Conf: {:?}", conf);
+ }
+
// Remove patterns and trim
for l in &mut *list {
*l = bullet.replace_all(&l, "").to_string();
}
fn input() -> (Conf, Vec<String>) {
+
let stdin = io::stdin();
let list: Vec<String> =
stdin.lock().lines()
}
fn normalize(mut arg: Vec<f64>) -> Vec<f64> {
+
let mut sum = 0.0;
for v in &arg {
sum += v;
arg
}
-
fn delta(n: i32) -> Vec<f64> {
+
const NAME: &str = "Delta";
const MEAN: f64 = 1.0; // unessential thanks to normalization
let mut prio: Vec<f64> = Vec::new();
}
fn exp(n: i32) -> Vec<f64> {
+
const NAME: &str = "Exp";
const RATE: f64 = 1.0; // rate is unessential thanks to normalization
let dist = Exp::new(RATE).unwrap();
normalize(prio)
}
-
fn lognormal(n: i32, std: f64) -> Vec<f64> {
+
const NAME: &str = "Lognormal";
const MEAN: f64 = 0.0; // mean is unessential thanks to
// normalization, and std of N
normalize(prio)
}
+#[derive(Debug)]
+
struct Conf {
bullet: String,
}
}
fn main() {
+
let args = Args::parse();
// let mut skew = 1.0;
}
output(&conf, &prio, &ranked);
-
}
#[test]
.split("\n").map(|x| x.to_owned()).collect();
let (_, res) = winnow(arg);
assert_eq!(exp, res);
-
}
#[test]
fn bullets() {
let arg: Vec<String> =
- "\n * Hej du\t\n - glade\n-\tta en\n\n" // Convert &str to String
- .split("\n").map(|x| x.to_owned()) // with `.to_owned()` or
- .collect(); // `.to_string()`
+ "\n * Hej du\t\n - glade\n-\tta en\n\n"
+ .split("\n").map(|x| x.to_owned())
+ .collect();
let exp: Vec<String> =
"Hej du\nglade\nta en"
.split("\n").map(|x| x.to_owned()).collect();
- let (conf, res ) = winnow(arg);
+ let (conf, res) = winnow(arg);
assert_eq!(exp, res);
assert_eq!(conf.bullet, " * ".to_owned());
#[test]
fn prioinput() {
+
let arg: Vec<String> =
" - 70 % Hej du\n - 30 %\tglade\nta en\n"
.split("\n").map(|x| x.to_owned())
fn bullout() {
let conf = Conf {bullet: " * ".to_owned()};
+
let prio = vec![0.6, 0.3, 0.1];
let ranked: Vec<String> =
"Hej du\nglade\nta en"