Skip to content

Commit 474f8a7

Browse files
authored
Merge pull request #326 from Aras14HD/larger-tuple-names
2 parents f8558d2 + c8a7a9a commit 474f8a7

File tree

6 files changed

+61
-15
lines changed

6 files changed

+61
-15
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

factorion-bot-discord/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "factorion-bot-discord"
3-
version = "2.3.1"
3+
version = "2.4.0"
44
edition = "2024"
55
description = "factorion-bot (for factorials and related) on Discord"
66
license = "MIT"
@@ -10,7 +10,7 @@ keywords = ["factorial", "termial", "bot", "math", "discord"]
1010
categories = ["mathematics", "web-programming", "parser-implementations"]
1111

1212
[dependencies]
13-
factorion-lib = { path = "../factorion-lib", version = "4.3.1", features = ["serde", "influxdb"] }
13+
factorion-lib = { path = "../factorion-lib", version = "4.4.0", features = ["serde", "influxdb"] }
1414
serenity = { version = "0.12", default-features = false, features = ["client", "gateway", "rustls_backend", "model", "cache"] }
1515
tokio = { version = "1.48.0", features = ["macros", "rt-multi-thread", "time"] }
1616
dotenvy = "^0.15.7"

factorion-bot-reddit/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "factorion-bot-reddit"
3-
version = "5.4.2"
3+
version = "5.5.0"
44
edition = "2024"
55
description = "factorion-bot (for factorials and related) on Reddit"
66
license = "MIT"
@@ -10,7 +10,7 @@ keywords = ["factorial", "termial", "bot", "math"]
1010
categories = ["mathematics", "web-programming", "parser-implementations"]
1111

1212
[dependencies]
13-
factorion-lib = {path = "../factorion-lib", version = "4.3.1", features = ["serde", "influxdb"]}
13+
factorion-lib = {path = "../factorion-lib", version = "4.4.0", features = ["serde", "influxdb"]}
1414
reqwest = { version = "0.12.28", features = ["json", "native-tls"], default-features = false }
1515
serde = { version = "1.0.219", default-features = false, features = ["derive"] }
1616
serde_json = "1.0.140"

factorion-lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "factorion-lib"
3-
version = "4.3.1"
3+
version = "4.4.0"
44
edition = "2024"
55
description = "A library used to create bots to recognize and calculate factorials and related concepts"
66
license = "MIT"

factorion-lib/src/calculation_results.rs

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,31 @@ impl Calculation {
435435
"", "mill", "bill", "trill", "quadrill", "quintill", "sextill", "septill", "octill",
436436
"nonill",
437437
];
438-
const BINDING_T: [[bool; 10]; 4] = [
438+
const TEN_THOUSANDS: [&str; 10] = [
439+
"",
440+
"decill",
441+
"vigintill",
442+
"trigintill",
443+
"quadragintill",
444+
"quinquagintill",
445+
"sexagintill",
446+
"septuagintill",
447+
"octogintill",
448+
"nonagintill",
449+
];
450+
const HUNDRED_THOUSANDS: [&str; 10] = [
451+
"",
452+
"centill",
453+
"ducentill",
454+
"tricentill",
455+
"quadringentill",
456+
"quingentill",
457+
"sescentill",
458+
"septingentill",
459+
"octingentill",
460+
"nongentill",
461+
];
462+
const BINDING_T: [[bool; 10]; 6] = [
439463
// Singles
440464
[
441465
false, false, false, false, false, false, false, false, false, false,
@@ -448,14 +472,22 @@ impl Calculation {
448472
[
449473
false, false, false, false, false, false, false, false, false, false,
450474
],
475+
// Tenthousands
476+
[
477+
false, false, false, false, false, false, false, false, false, false,
478+
],
479+
// Hundredthousands
480+
[
481+
false, false, false, false, false, false, false, false, false, false,
482+
],
451483
];
452484
if let Some(s) = locale.num_overrides().get(&level) {
453485
return s.as_ref().into();
454486
}
455487
match level {
456488
0 => locale.sub().as_ref().into(),
457489
1 => "{factorial}".into(),
458-
..=9999 if !locale.force_num() => {
490+
..=999999 if !locale.force_num() => {
459491
let singles = if level < 10 { SINGLES_LAST } else { SINGLES };
460492
let mut acc = String::new();
461493
let mut n = level;
@@ -469,9 +501,15 @@ impl Calculation {
469501
n /= 10;
470502
acc.write_str(HUNDREDS[h as usize]).unwrap();
471503
let th = n % 10;
504+
n /= 10;
472505
acc.write_str(THOUSANDS[th as usize]).unwrap();
506+
let tth = n % 10;
507+
n /= 10;
508+
acc.write_str(TEN_THOUSANDS[tth as usize]).unwrap();
509+
let hth = n % 10;
510+
acc.write_str(HUNDRED_THOUSANDS[hth as usize]).unwrap();
473511
// Check if we need tuple not uple
474-
let last_written = [s, t, h, th]
512+
let last_written = [s, t, h, th, tth, hth]
475513
.iter()
476514
.cloned()
477515
.enumerate()
@@ -724,8 +762,16 @@ mod tests {
724762
"unvigintricenquadrilluple-{factorial}"
725763
);
726764
assert_eq!(
727-
Calculation::get_factorial_level_string(10000, &en.format()),
728-
"10000-{factorial}"
765+
Calculation::get_factorial_level_string(89342, &en.format()),
766+
"duoquadragintricennonilloctogintilluple-{factorial}"
767+
);
768+
assert_eq!(
769+
Calculation::get_factorial_level_string(654321, &en.format()),
770+
"unvigintricenquadrillquinquagintillsescentilluple-{factorial}"
771+
);
772+
assert_eq!(
773+
Calculation::get_factorial_level_string(1000000, &en.format()),
774+
"1000000-{factorial}"
729775
);
730776
let de = locale::get_de();
731777
assert_eq!(

factorion-lib/tests/integration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ fn test_get_reply_for_high_multifactorial() {
10431043
meta: (),
10441044
calculation_list: vec![Calculation {
10451045
value: 10.into(),
1046-
steps: vec![(12345, false)],
1046+
steps: vec![(1234567, false)],
10471047
result: CalculationResult::Exact(Integer::from(10)),
10481048
}],
10491049
notify: None,
@@ -1056,7 +1056,7 @@ fn test_get_reply_for_high_multifactorial() {
10561056
let reply = comment.get_reply(&consts);
10571057
assert_eq!(
10581058
reply,
1059-
"12345-factorial of 10 is 10 \n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*"
1059+
"1234567-factorial of 10 is 10 \n\n\n*^(This action was performed by a bot | [Source code](http://f.r0.fyi))*"
10601060
);
10611061
}
10621062

0 commit comments

Comments
 (0)