Eifrige (eager) Auswertung

Das geht gut:

int fac (int x) {
    if (x>0) { return x * fac (x-1); }
    else     { return 1; } 
}

aber das nicht (in Java usw.):

int if_positive (int x, int j, int n) {
    if (x > 0) { return j; } else { return n;}
}
int fac (int x) {
    return if_positive (x, x*fac(x-1), 1);
}

(welche Lösung/Hack in C?)



Johannes Waldmann 2008-01-23