Well, there's no need to apply N Y to zero!
So, for example,

   N Y"0] 1 1 2 3 5 8
1 1 1 2 5 21
   N Y 20
6765

It took me a while to understand N Y ,  as I was confusing the right argument, the index i of an element ai in the sequence, a0 a1 a2 ... ai ...,  with its value.
N Y actually executes the definition of the general term, ie
    ai = a(i-2) + a(i-1)
by means of ($:@<:@<:) + ($:@<:) ,  which recur on intermediate decreasing "i" . The ^:(1 < ]) ensures termination for i in 0 1,  and so "defines" a0 = 0, a1 = 1.
Brilliant!

This correspondence has been an eye-opener on $:,  which I'd never got the
hang of,  as well as an introduction to evoke gerund.

Cheers,

Mike


On 30/11/2018 06:18, Linda Alvord wrote:
Y=: ($:`)(`:6)
N=: 1 :'(u@:<:@:<: + [:u<:)^:(1 < ])'
N=: (5!:1)<'N'


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to