B:BD[
3.2257] → [
3.2257:2467]
B:BD[
3.2467] → [
2.11192:11223]
∅:D[
2.11223] → [
3.2494:2648]
B:BD[
3.2494] → [
3.2494:2648]
∅:D[
3.2648] → [
4.37669:37702]
B:BD[
4.37668] → [
4.37669:37702]
B:BD[
4.37702] → [
3.2649:2721]
B:BD[
3.2721] → [
2.11224:11428]
∅:D[
2.11428] → [
3.2903:2956]
B:BD[
3.2903] → [
3.2903:2956]
B:BD[
3.2956] → [
2.11429:11653]
∅:D[
2.11653] → [
3.3131:3212]
B:BD[
3.3131] → [
3.3131:3212]
B:BD[
3.3212] → [
2.11654:11862]
∅:D[
2.11862] → [
3.3398:3479]
B:BD[
3.3398] → [
3.3398:3479]
B:BD[
3.3479] → [
2.11863:12074]
∅:D[
2.12074] → [
3.3668:3678]
B:BD[
3.3668] → [
3.3668:3678]
impl IndicesWithPrefixes<'_> {
fn generate_verse(&self, n: u32) -> String {
let n = n as usize;
let mut out = String::with_capacity(if n > 2 {
LENGTHS[3] + 2 * integer_length(n) + integer_length(n - 1)
} else {
LENGTHS[n]
});
self.0.iter().for_each(|(prefix, indices)| {
out.push_str(prefix);
indices.iter().for_each(|index| out.push_str(DICT[*index]));
});
out
}
}
pub fn verse(n: u32) -> String {
match n {
0 => {
let mut out = String::with_capacity(LENGTHS[0]);
[
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2, 3, 4, 5, 12, 13, 7, 8, 14, 2, 15, 16,
8, 17, 2, 10, 18, 3, 4, 5, 6, 7, 8, 9, 12,
]
.iter()
.for_each(|index| out.push_str(DICT[*index]));
out
}
1 => {
let n_string = n.to_string();
IndicesWithPrefixes(&[
(&n_string, &[3, 5, 6, 7, 8, 9, 10]),
(
&n_string,
&[
3, 5, 12, 19, 20, 21, 15, 22, 20, 23, 10, 11, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12,
],
),
])
.generate_verse(n)
}
2 => {
let (n_string, m_string) = (n.to_string(), (n - 1).to_string());
IndicesWithPrefixes(&[
(&n_string, &[3, 4, 5, 6, 7, 8, 9, 10]),
(&n_string, &[3, 4, 5, 12, 19, 6, 8, 21, 15, 22, 20, 23, 10]),
(&m_string, &[3, 5, 6, 7, 8, 9, 12]),
])
.generate_verse(n)
}
_ => {
let (n_string, m_string) = (n.to_string(), (n - 1).to_string());
IndicesWithPrefixes(&[
(&n_string, &[3, 4, 5, 6, 7, 8, 9, 10]),
(&n_string, &[3, 4, 5, 12, 19, 6, 8, 21, 15, 22, 20, 23, 10]),
(&m_string, &[3, 4, 5, 6, 7, 8, 9, 12]),
])
.generate_verse(n)
}
}
}
// Might not work properly if results of `powi`s don't fit into the `usize` casts.