(1 1 1 1j1 1) ([# #&.|: ) >:i. 5 5 1 2 3 4 0 5 6 7 8 9 0 10 11 12 13 14 0 15 16 17 18 19 0 20 0 0 0 0 0 0 21 22 23 24 0 25
R.E.Boss -----Oorspronkelijk bericht----- Van: [email protected] [mailto:[email protected]] Namens Matthew Brand Verzonden: zaterdag 10 januari 2009 11:20 Aan: Programming forum Onderwerp: Re: [Jprogramming] Matrix spread 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 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
