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 <[email protected]> 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 <[email protected]>
> Date: Sun, Nov 25, 2012 at 4:24 PM
> Subject: Boxing by columns
> To: Programming forum <[email protected]>
>
>
> 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