Hi Matt,
On 12/15/05, Matt O'Connor <angagon / earthlink.net> wrote:
> Though a more "functional approach" is to hide the helper function:
I don't think this actually hides the helper function:
def fib n
def fib_helper n, next_val, val
n < 1 ? val : fib_helper( n-1, next_val + val, next_val)
end
fib_helper( n, 1, 1)
end
p fib(10) => 89
p fib_helper(10,1,1) => 89
Wayne
---
Wayne Vucenic
No Bugs Software
"Ruby and C++ Agile Contract Programming in Silicon Valley"