Hacker News new | ask | show | jobs
by ngcazz 546 days ago
Have always appreciated Haskell's tail-recursive one

  fib = (fibs !!)
      where fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
    
  main = putStrLn $ show $ fib 1000
1 comments

You probably just jest, either way fibs is not tail recursive [0], since its returning value is a list constructor, and not a call to itself.

[0] : https://stackoverflow.com/questions/33923/what-is-tail-recur...

No jest, I just recalled this formulation incorrectly as being tail-recursive. Thanks for reminding me.