How can you write the Haskell fibs in C? I mean the
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
fibs.
Name:
Anonymous2008-06-16 15:40
>>38
This is why I hate programming -- you do something small and get big effects. Where's the logic in this?
Name:
Anonymous2008-06-16 17:40
>>39 static fibs[2] = {0, 1}; fibs = realloc(fibs, i)
What compiler supports this kind of absurdity?
>>41
It's pretty obvious if you understand what the code is doing, which isn't hard at all in >>12,38's case.
Name:
Anonymous2008-06-16 18:24
>>42
wow, i didn't think anyone here would notice that. i guess i'm not the only person on /prog/ who actually knows c.
it's trivial to fix if you know why it doesn't work.
Name:
Anonymous2008-06-16 18:37
?- dynamic fib/2
fib(0,0).
fib(1,1).
fib(N,A):- N > 0, N1 is N-1, N2 is N-2, fib(N1,A1),
fib(N2,A2), A is A1 + A2, asserta(fib(N,A)).
Name:
Anonymous2008-06-16 18:58
>>43 i guess i'm not the only person on /prog/ who actually knows c.
lol
Name:
Anonymous2008-06-16 21:55
>>43
There's 15 people on /prog/ and, from what I've seen, at least 6 of us know C.
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy