I wanted to be able to write a modifier that looks like (u1 A1) , (u2 A2) , (u3 A3), whilst also being able to specify each of these verbs individually. My approach was to provide u1 and u3 together, as u1`u3, and then use adverbs to process u1`u3 back into u1 and u3 inside the modifier, e.g.:
three_argument_modifier=:([. get_u1 A1) , (]. A2) , ([. get_u3 A3) NB. rough pseudocode
I should have mentioned in my first post that the intent is for the modifier train to evaluate to a noun (so that it can then be used in (...)`:6 to produce the correct verb).
My original implementation of "get_u1" was (using (NVC)V to effectively create an ""NVA fork""):
first_verb=:(0 { ([.`''))`:6 ] NB. accepts either a verb or a gerund, and (interpreting it as a list of verbs) evaluates to the first verb provided
and this is where ran into the syntax error that I then reproduced in my original post.
Some solutions are:
first_verb=:((]:`'' {~ 0"_) ([.].) '')`:6 NB. using the original solution I mentioned
first_verb=:(0&{@(]:`'') ([.].) '')`:6 NB. using the solution you provided
first_verb=:(0&{ ([.].) ]:`'')`:6 NB. an extra solution (N&V ([.].) A) inspired by your solution
The broader context is that I am writing an interpreter in J, and I wanted testing verbs to create sample nouns that might appear as the results of parsing code, and in my case, these nouns all have a similar structure that would benefit from generating all the verbs from a common modifier. I am currently writing the part of the interpreter that executes the code, and wanted to be able to test it separately from the parser.
Having said this, however, I decided to forgo writing verbs specifically to create testing data, and simply use the parsing verbs directly to create the data from a sample code snippets. (I am reasonably convinced the parsing verbs work as intended, due to the way they were written.)
Thanks for the fast response + insight,
Helen