// Lindenmayer Challenge
// Program: DravinsIvo.cpp
#include
#include
// POST: the word w_i^F is drawn
void f (const unsigned int i) {
if (i == 0)
ifm::forward(90); // F
else {
f(i-1); // w_{i-1}^F
ifm::left(90); // -
ifm::save(); // [ stores current position and direction
ifm::left(90); // -
f(i-1); // w_{i-1}^F
ifm::right(90); // +
f(i-1); // w_{i-1}^F
ifm::right(90); // +
f(i-1); // w_{i-1}^F
ifm::restore(); // ] goes back to last stored position / direction
ifm::jump();
ifm::right(90); // +
ifm::save(); // [
ifm::right(90); // +
f(i-1); // w_{i-1}^F
ifm::left(90); // -
f(i-1); // w_{i-1}^F
ifm::left(90); // -
f(i-1); // w_{i-1}^F
ifm::restore(); // ]
}
}
int main () {
std::cout << "Number of iterations =? ";
unsigned int n;
std::cin >> n;
// draw w_n = w_n^F
ifm::left(90); // loook up
f(n); // w_n^F
return 0;
}