Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Fibs in C

Name: Anonymous 2008-06-14 10:50

How can you write the Haskell fibs in C? I mean the

fibs = 0 : 1 : zipWith (+) fibs (tail fibs)

fibs.

Name: Anonymous 2008-06-16 15:14

>>12,16
If you invert the call order, it only destroys half as much stack.

int fibarray[MAX_FIBS] = {1,1};

int fib(int n)
{
   return fibarray[n] ? fibarray[n]
                      : fibarray[n] = fib(n-2) + fib(n-1);
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List