From: Gustav Eek Date: Thu, 2 Feb 2023 08:10:00 +0000 (+0100) Subject: Src. Implement option for distribution X-Git-Tag: v.0.3~1 X-Git-Url: https://git.g-eek.se/?a=commitdiff_plain;h=961f3dbae662fa81322de44d9074fdd9a99c1058;p=ranknauto.git Src. Implement option for distribution --- diff --git a/src/main.rs b/src/main.rs index 7a194d9..56721ab 100644 --- a/src/main.rs +++ b/src/main.rs @@ -101,7 +101,11 @@ fn lognormal(n: i32, std: f64) -> Vec { struct Args { - /// Ranking distribution skewness + /// Ranking distribution + #[arg(short, default_value_t = String::from("lognormal"))] + distribution: String, + + /// Skewness of the ranking #[arg(short)] skewness: Option, } @@ -129,9 +133,14 @@ fn main() { let ranked: Vec = input(); let num = ranked.len() as i32; - let _prio1 = delta(num); - let _prio2 = exp(num); - let prio3 = lognormal(num, skew); + + let prio = if args.distribution == String::from("delta") { + delta(num) + } else if args.distribution == String::from("exponential") { + exp(num) + } else { // Default + lognormal(num, skew) + }; if DEBUG { for l in ranked.iter() { @@ -140,6 +149,6 @@ fn main() { eprintln!("\x08\x08."); } - output(&prio3, &ranked); + output(&prio, &ranked); }