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-15 12:05

OMG OPTIMIZED

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

int fib(int n)
{
   while(last < n) fibarray[last+1] = fibarray[last++] + fibarray[last-1];
   return fibarray[n];
}

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