Function malachite_base::strings::exhaustive::exhaustive_strings_using_chars
source · pub fn exhaustive_strings_using_chars<I: Clone + Iterator<Item = char>>(
cs: I,
) -> StringsFromCharVecs<ExhaustiveVecs<char, PrimitiveIntIncreasingRange<u64>, I>> ⓘ
Expand description
Generates all [String
]s with char
s from a specified iterator.
If cs
is empty, the output length is 1; otherwise, the output is infinite.
The lengths of the output [String
]s grow logarithmically.
§Complexity per iteration
$T(i) = O(\log i)$
$M(i) = O(\log i)$
where $T$ is time and $M$ is additional memory.
§Examples
use itertools::Itertools;
use malachite_base::strings::exhaustive::exhaustive_strings_using_chars;
let ss = exhaustive_strings_using_chars('x'..='z')
.take(20)
.collect_vec();
assert_eq!(
ss.iter().map(String::as_str).collect_vec().as_slice(),
&[
"", "x", "y", "xxx", "z", "xx", "xy", "xxxxx", "yx", "xxy", "yy", "xxxx", "xz", "xyx",
"yz", "xxxxxx", "zx", "xyy", "zy", "xxxy"
]
);