Ok, so, for this problem, I'd probably have used representative simplifications, perhaps something like this:
tabprint=: {&'.@' xtable=: ?5 5$2 table=: ?5 5$2 I might have also used several different threads to ask all the questions.. (for example, if you wanted to preserve the shapes of the individual "pages" you'd need to put them in boxes, and that winds up making more sense posed in a different thread from a question about screen clearing). But optimal... that's a tricky one. Optimal in one example can be a poor fit in another example. The optimal way might be something like this: builder"_1 data where 'builder' produces a rank 2 result and items in data are sufficient to produces each of those rank 2 results... That said, if you've gotten the answers you need, I guess that's good enough. Good luck, -- Raul On Sun, Dec 24, 2017 at 9:50 AM, Nick S <simic...@gmail.com> wrote: > Sorry. I am too close to the problem. table and xtable are rank 2 boolean > tables of size 5 5, 10 10, 15 15, or 20 20. > > Tabprint is rather complex, and pulls in data from both table and xtable > but also from other vectors and so forth. But for > the environment it is in, it will always produce a rank 2 table of > characters and ($tabprint table) -: ($tabprint xtable) will be true for any > run. The size will only change when the inputs change - that is, when it is > working on a different problem. It uses @ and . to represent 0 and 1 so > that you can more visually see the bits, since pattern is important, also > uses flags to indicate completion status for each row and column, and also > represents the vector of groups used to build the table in right justified > character form (vertically represented for the columns bottom justified). > But that was not really germane to what I was asking about. > > I was trying to print a representation of table and xtable side by side > after each run of this iterative solver since even though I wrote it, I am > trying to see how it actually works and how its approach to a solution > compares to mine by flipping through the pages. For a recent run and a 15 > by 15 table, the output has size and rank as follows: > > $recordtables > > 5 26 82 > > > I have seen the first number get as high as 24. > > I can show you cases where I did do a thorough exposition of a problem I > was having, including enough background that it was completely explained, > including why I had made design decisions, and the response was, "wall of > words" and the end result is that I got no helpful answers. So I try to > abbreviate - and if I do put in background, I do what I did in the first > case. In this case, though, what I posted was a working piece of code. I > was just asking if I had found an optimal way of building the rank 3 table > out of rank 2 tables. > > > > On Sun, Dec 24, 2017 at 8:42 AM, Raul Miller <rauldmil...@gmail.com> wrote: > >> You are not giving enough detail of what's going on here to really comment. >> >> For example, in your expression: >> >> recordtables =: recordtables,,: ((tabprint table),"1 (tabprint xtable)) >> >> you have not mentioned anywhere what xtable is like, nor what tabprint is >> like. >> >> So you've presented an example which is probably some unknown data >> element is being processed by an unknown verb to give an unknown >> result, and you seem to be asking for comments on how to do that >> better. But we are reduced to guessing, because we have no idea what >> you are talking about. >> >> That said, you did give us >> >> recordtables =: 0 0 0 $ '' >> >> So, if the result of tabprint is rank 2 (if #$tabprint xxx always >> gives a result of 2), then your recordtables expression could be >> simplified to: >> >> recordtables =: recordtables, (tabprint table),"1 tabprint xtable >> >> and it could be further simplified to: >> >> recordtables =: recordtables, table ,.&tabprint xtable >> >> On the other hand, for example, if >> 1 -: #$tabprint table >> 2 -: #$tabprint xtable >> >> then replacing ,"1 with ,. will not work (because ,. forms rank 1 >> items into a column)... >> >> Anyways.. I think it's good practice to give representative examples >> and/or documentation for each of the words involved in the J sentence >> you're asking about. (And this same basic concept applies in any >> language. >> >> Generally speaking "it doesn't work" is not a question when we do not >> know what "it" is nor what "working" would look like... >> >> We can guess, and sometimes maybe get it right, but we can also guess >> and get it wrong. >> >> Thanks, >> >> -- >> Raul >> >> >> On Sun, Dec 24, 2017 at 4:09 AM, Nick S <simic...@gmail.com> wrote: >> > OK, so basically I was doing the rank wrong. Thanks. I wish I >> understood >> > verb rank well enough to understand why I was doing it wrong. I was >> trying >> > to make a list of pages. Basically, I was trying to make a rank 3 list >> of >> > rank 2 page images. I could have made a vector of boxed images but they >> > were all the same. Through trial and error I ended up initializing with >> > >> > recordtables =: 0 0 0 $ '' >> > >> > and adding pages with >> > >> > recordtables =: recordtables,,: ((tabprint table),"1 (tabprint xtable)) >> > >> > but I get the feeling that if I really understood verb ranks I could do >> it >> > with fewer operators. Maybe what I am doing is optimum. >> > >> > On Sat, Dec 23, 2017 at 12:52 PM, Henry Rich <henryhr...@gmail.com> >> wrote: >> > >> >> To modify acolumn: >> >> >> >> 97 98 99 (2})"0 1 i. 3 3 >> >> >> >> 0 1 97 >> >> >> >> 3 4 98 >> >> >> >> 6 7 99 >> >> >> >> >> >> Henry Rich >> >> >> >> >> >> >> >> >> >> On 12/23/2017 12:48 PM, Nick S wrote: >> >> >> >>> I have a 3d array that is the formatted output of a table. I capture >> >>> snapshots of it at different points in my processing, in a rank 3 >> array. I >> >>> want to flip between pages to see how the processing progresses. I >> >>> thought >> >>> I would clear the screen, then display the output, that being one of >> the >> >>> stacked sheets. Can someone point me in the right direction? I have >> >>> researched this for hours and just can't find the right manual or >> google. >> >>> >> >>> Now, I manipulate this table column by column and row by row, >> Somewhere I >> >>> read that amend would update anything that from would fetch. But I >> find >> >>> that to be wrong. >> >>> >> >>> I was able to fetch a row of my table with >> >>> >> >>> buildline =: (<: | y){table >> >>> >> >>> >> >>> and a column with >> >>> >> >>> >> >>> buildline =: (y){"1 table >> >>> >> >>> >> >>> but >> >>> >> >>> >> >>> table =: bitvector (y)}"1 table >> >>> >> >>> >> >>> would not work. >> >>> >> >>> I can update a row with >> >>> >> >>> table =: (accumand)(<: | y) } table >> >>> >> >>> >> >>> but the column is more difficult. I came up with two approaches. One >> way >> >>> was to transpose the table, update what was now a row, and then >> transpose >> >>> the result. >> >>> >> >>> >> >>> table =: |: (accumand) (y) } |:table >> >>> >> >>> >> >>> What I settled on was to build a boxed set of coordinates >> >>> >> >>> >> >>> table =: (accumand) (<(i.tsize);y) } table >> >>> >> >>> >> >>> >> >>> it probably does not matter for my application, we are talking, at the >> >>> largest, 20x20 boolean arrays. I am wondering if I need to throw >> around >> >>> more data. >> >>> >> >>> >> >>> >> >>> (The above is the limit of my questions.) >> >>> >> >>> (y can be a zero or positive scalar, indicating a column, or a scalar >> from >> >>> -tsize to _1 - (generated with }:i: tsize) which indicates a row. >> >>> >> >>> >> >>> For further information, the program solves one of those solitare games >> >>> where you have a series of numbers, and you get numbers for every row >> and >> >>> every column. Suppose that the numbers for column 1 were 8,3,4, this >> >>> regular expression would have to match: >> >>> >> >>> >> >>> >> >>> >> >>> ^0*1{8,8}0+1{3,3}0+1{4,4}0*$ >> >>> >> >>> >> >>> Table size is fixed based on the puzzle, but can vary between 5 and 20. >> >>> >> >>> >> >>> Anyway, I did a lot of if. then. else. stuff because my first simple >> >>> version of the program took over 700 seconds to do one round of >> >>> calculations on a single row or column and the most rounds I have seen >> a >> >>> puzzle take is 17 iterations before it could place all the marks, and >> with >> >>> aggressive early pruning, I was able to get about 2 orders of magnitude >> >>> improvement. I process 400 rows+columns in under 2 seconds. If you >> have >> >>> a line where the numbers are, say, 1 1 1 1 1 1, it would generate >> >>> thousands >> >>> of potential solutions, which would result in naught if there were no >> >>> other >> >>> constraints - so I prune those cases - I don't process those lines >> until I >> >>> detect a constraint on that line because without a constraint I will >> not >> >>> learn anything. >> >>> >> >>> >> >>> On a personal note, I find that I can get obsessed with solitare games >> to >> >>> the exclusion of everything else I want to do. It helps to break the >> >>> obsession if I write a solver. >> >>> >> >>> >> >>> >> >>> >> >> >> >> >> >> --- >> >> This email has been checked for viruses by AVG. >> >> http://www.avg.com >> >> ---------------------------------------------------------------------- >> >> For information about J forums see http://www.jsoftware.com/forums.htm >> > >> > >> > >> > >> > -- >> > 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 >> > > > > -- > 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