The verb below will do it:
ins1 =: (4 : '(x&#)&.|: x # y')
Can anybody help me with a common problem I run into when trying to do
things using tacit expressions?
My thinking would be that I want to do x # y ...
(1 1 1 1j1 1) ( # ) >:i. 5 5
... followed by "under rotating the result" do x # on "the rotated result".
I end up writing this:
(1 1 1 1j1 1) ( (#&.|:)@:# ) >:i. 5 5
Now I know it is wrong, and why it is wrong, but I just get stuck. I need to
get the left argument passed to the (#&.|:) by the @:, and then I need to
get it passed also to the # by the &. ... so I alter the @:# to be @:([;#)
intending to unpack the left argument later.
I.e. I know I can pass the left argument through the @: by doing this:
(1 1 1 1j1 1) ( (0&{::)@:([;#) ) >:i. 5 5
But now I have got very messy code.
I stop here because if I carry on like this then I will have to do another
pack and unpack for the &.|: adverb to pass the left argument to its # verb.
What is the more elegant way to turn expressions such as (4 : '(x&#)&.|: x #
y') into tacit expressions? Does anyone have any tips for the problem I
often encounter with passing the left argument through @: and &. ?
I often end up writing in-line explicit functions like (4 : '(x&#)&.|: x #
y') where I think I should be using a tacit expression instead but I am not
fluent enough in J to write them.
Obviously in this example I could use:
(1 1 1 1j1 1) ( [ #"1 [ # ]) >:i. 5 5
Which is the same as Brian Scott's (not sure about that apostrophe):
1 1 1 1j1 1 #"1]1 1 1 1j1 1 #>:i. 5 5
but in other problems I often seem to need to pass the left argument through
the @:, @ and &. .
Thanks,
Matthew.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm