12 Meta m(
"generator",
"fib",
"Generates the n-th Fibonacci word.");
18 if(n == 1)
return "b";
19 if(n == 2)
return "a";
21 std::string vold =
"b";
22 std::string old =
"a";
24 vold.reserve(std::pow(1.62, n-1));
25 old.reserve(std::pow(1.62, n));
27 for(
size_t i = 2; i < n; ++i) {
28 std::string tmp = old + vold;
33 DCHECK_LE(old.length(), std::pow(1.62, n));
34 DCHECK_LE(vold.length(), std::pow(1.62, n-1));
38 using Generator::Generator;
40 inline virtual std::string
generate()
override {
Contains the text compression and encoding framework.
virtual std::string generate() override
Generates a string based on the environment settings.
static std::string generate(size_t n)
Generates the n-th Fibonacci word.
Env & env()
Provides access to the environment that the algorithm works in.
Base for string generators.