3 ms·
How? Giving f(N) in terms of f(N) hardly seems useful, in any language. (It's hard to tell if you're joking without a smiley.)
by jcl 17y ago
How? Giving f(N) in terms of f(N) hardly seems useful, in any language. (It's hard to tell if you're joking without a smiley.)
- eru 17y agoI am too dumb / lazy to think of an example for the fibonaccy numbers at the top of my head. But suppose your problem was giving a list of natural numbers, then giving a circular definition like > naturals = 0 : (map (+1) naturals) actually works in Haskell. (In Haskell a:b means the same as (cons a b) in Lisp. I also added parens to make the definition more readable for non-Haskellers.)
- jcl 17y agoSo, that actually works by establishing a base value and a derivation step... i.e., it defines N(0), then it expresses N(n) in terms of N(n - 1). If you try to do the same thing for Fibonacci numbers, you would need to express F(n) in terms of earlier values, not in terms of F(n). What cperciva is jokingly proposing is the equivalent of: naturals = naturals which is hardly helpful for computing the values. Lazy languages would not help you there.