A nice cut. Here's a version without boxes. ]ar=:>:?9 4 $ 9 6 4 3 5 1 9 9 4 2 4 8 7 7 2 2 3 7 8 1 1 3 4 5 4 7 8 6 4 4 9 4 2 2 4 9 7 (~.)"1 |: ar 6 1 2 7 3 4 0 0 4 9 2 8 0 0 0 0 3 9 8 2 1 5 6 4 5 4 7 3 1 2 0 0 (+/"1) 0~: (~.)"1 |: ar 6 4 8 6
Linda -----Original Message----- From: programming-boun...@forums.jsoftware.com [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Dan Bron Sent: Monday, November 26, 2012 12:59 PM To: J Programming Subject: Re: [Jprogramming] Fwd: Boxing by columns Have you tried ('';1) <;.1 table? Cut is one of the few primitives which can directly address non-leading dimensions. -Dan Please excuse typos; composed on a handheld device. On Nov 25, 2012, at 8:05 PM, Nick Simicich <simic...@gmail.com> wrote: > I am trying to use the new gmail - and I have no idea why this partial > message was sent prematurely. I apologize, please ignore the earlier > version. > > ---------- Forwarded message ---------- > From: Nick Simicich <simic...@gmail.com> > Date: Sun, Nov 25, 2012 at 4:24 PM > Subject: Boxing by columns > To: Programming forum <programm...@jsoftware.com> > > > OK, I have a simple problem. I am writing a mathdoku helper in J, > just for grins (and because it can run on my Android phone). > > At one point I have what might a number of solutions (generally > between 10 and a max of a couple hundred). They will be in a variable > that will contain each solution boxed. Thus, it will look like: > > [1 2 3 4][4 2 3 1][3 1 2 4] etc. Each solution has the same length. > > I need to look at the contents of each column. Essentially, I want to > take the nub of each column and sort the results for display - so that > I can display the possible results at each position. > > So I want to take this variable which is boxed by column and re-box it > by row. > > This is the routine I am currently using to display my data: > > rr =: [: (([: (/:~) ~.)L:_1) ([: (<"_1) ([: |: >)) > > The above works. But it bothers me for this reason - I am transposing > the array here so that I can rebox it by row: > > (<"_1) ([: |: >) > > I am trying to determine if there is any way to take a two dimensional > array and to box the data in the array by column - I thought that > there was something I could specify in the rank for box, but I can't > figure out what it might be - or is there a better way to box by column? > > > > To try ans simplify, suppose you create an array with > > ar =: >: ?. 9 4 $ 9 > > If your random number generator and ?. works like mine does, > > +/,ar is 191 > > > <"_1 |: ar > > gives me 4 boxes - and with data of this size, it is not important > that you have transposed the data. If you had 1000000 rows (I have > tried it) there is a noticeable pause when you transpose. > > It is possible to extract a column with 0{"1 ar - or a row with 0{ ar > > It is possible to sum on columns or rows by using the rank adverb. > > But I can't figure out how to box by column - > > < ar produces a single box > <"1 ar boxes by row - 9 boxes. > <"_1 ar boxes by row. > > <"(1 _ 1) ar boxes by row. > > I have tried maybe 20 3 digit combinations and I can't get it to > select the columns and box them. > > Maybe there is no way to do this - I have asked a few questions here, > none for many months because once I understood more about rank some of > my questions went away. But this one issue escapes me - maybe someone > could undertake an answer and an explanation? Or an explanation as to > why it just won't work? > > I am thinking that an alternative would be to extract one column at a > time and then produce the boxes from those columns and stack them > together - but I am unsure of how to do that, either. > > And, again, I am sorry that I posted a partial unedited question. > > > -- > Of course I can ride in the carpool lane, officer. Jesus is my > constant companion. > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm