End-Rekursionen (tail recursion)

ein Spezialfall von End-Aufrufen sind End-Rekursionen.

Durch Auflösung von End-Rekursionen entstehen Schleifen.

void tabulate (int x) {
  if (x > 0) {
    printf ("%9d, %9d\n", 
            x, x*x*x);
    tabulate (x-1);
  }
}
void tabulate (int x) {
  start: if (x > 0) {
    printf ("%9d, %9d\n", 
            x, x*x*x);
    x = x-1; 
    goto start;
  }
}
Aufgabe: als while-Schleife?



Johannes Waldmann 2006-02-02