Here's a naive Fibonacci sequence:
(,[:+/_2&{.)^:10]0 1 NB. 10 + 2 elements
0 1 1 2 3 5 8 13 21 34 55 89
And here's its explicit monadic version:
3 :'(,[:+/_2&{.)^:y 0 1' 10
0 1 1 2 3 5 8 13 21 34 55 89
The questions is: in tacit definition, can I somehow supply rightmost argument to ^: conjunction, so as (off top of my head):
((,[:+/_2&{.)^:y 0 1)10
0 1 1 2 3 5 8 13 21 34 55 89
Will yield the expected result? Or, more correct definition (again, off top of my head):
((,[:+/_2&{.)^:(y-2)1 1)10
1 1 2 3 5 8 13 21 34 55
More generally: is it possible to tacitly define adverbs and conjunctions in J, or is it possible only with explicit definitions?
My gut (and material from this question) tells me that I should go to the dark side and learn more about gerunds and ` / `: conjunctions. Is that correct? If so, I would appreciate any newbie-friendly material on this matter :)
I think that my natural approach would be to create a dyadic verb where the left argument is the number of iterations and the right argument is the initial string. This allows me to extend the string easily.
I can create a verb monadically by filling in the
(,[:+/_2&{.)as the left argument to^:and10as the left argument. Not too flexible in extending the string though.And I end up faking the result that you may be looking for by attaching
0 1in the definition and creating a monadic verb looking for the number of iterations.But you wanted to know if there was a way to do this using adverbs tacitly. Taking what I have shown above you can create an adverb from the conjunction
^:by adding the verb(,[:+/_2&{.)to the left.