On 07/06/2017 02:21 AM, Ali Çehreli wrote:
On 07/05/2017 04:38 PM, helxi wrote:
[...]
>> recurrence!((a, n) => a[0] + 1)(1).take(10).writeln;
> 1. In the last example of reccurence, what does n in (a,n) refer to?
n is "the index of the current value". Each time the lambda is called,
a[n] is what is being generated
a[n-1] is the previous value
a[0] is the same as a[n-1]? (I find this confusing)
Looks like I was wrong when I stated that "a[0] refers to the previous
value". `a[0]` is actually invalid for n > 1.
The documentation for `recurrence` says you have to index relative to n,
and you can only go back as many values as you gave initially. I should
have used `a[n - 1]`.