Unfortunately, I do not know what "works" means. Maybe if this was wired up to a sudoku solver, I could see it in action -- I know how to test a sudoku solution for correctness.
Anyways, here's the case I am struggling with right now: A=: (|:++:) #:0 8 4 4 C=: (a:,];|:) #:0 6 11 1 D=: #:9 0 0 4 (0{"1 ($#:I.@,)*A) *.//. ((> @ {&C @ {::&A) revDom ({&D))"1 ($#:I.@,)*A This is actually a rather boring case, the result here is 4 4 $ 0, but I want to make sure that those zeros are being generated in a way that I understand. So... If I look at an intermediate result here: (({&D))"1 ($#:I.@,)*A I get a sequence of pairs of rows selected from D And, if I look at subsequent intermediate results: ([: getx ({&D))"1 ($#:I.@,)*A ([: gety ({&D))"1 ($#:I.@,)*A I can see that we are pulling out the first and second of the pairs of rows. So here's the issue I am struggling with: are the values represented here by the row index and column index in A both valid as row indices into D, or should the column index in A be a column index in D? The comment on D says: NB.* 'D' is the domain of each variable, one row per variable. but I am not sure what that means. The comment on A says: NB.* 'A' an adjacency matrix (which constraint is between a pair of variables). I think I know what that means, but my supposed understanding is not helping me understand D. Any insights appreciated. Thanks, -- Raul On Sun, Nov 4, 2012 at 2:30 PM, Raul Miller <rauldmil...@gmail.com> wrote: > I'm blathering a lot here, sorry about that, but I found a case, now I > just need to understand it: > > A=: (|:++:) #:0 8 4 4 > C=: (a:,];|:) #:0 6 11 1 > D=: #:9 0 0 4 > > Now to see if I can understand what's happening here... > > I will try to refrain from posting my incomplete thoughts -- I'll try > to come back with something that works. > > Thanks, > > -- > Raul > > On Sun, Nov 4, 2012 at 2:18 PM, Raul Miller <rauldmil...@gmail.com> wrote: >> In revise, you are using a pair for your right argument. >> >> It looks to me like this might be unnecessary -- that you could use >> ys=. I.+./"1 D >> >> But this does not exactly reproduce your algorithm. So if this change >> breaks your algorithm, could you find an example situation which >> illustrates this issue? >> >> Thanks, >> >> -- >> Raul >> >> On Fri, Nov 2, 2012 at 1:01 AM, Michal D. <michal.dobrog...@gmail.com> wrote: >>> Hi All, >>> >>> I've managed to write my first not-completely-trivial program in J. It >>> implements an arc consistency algorithm ( >>> http://en.wikipedia.org/wiki/Local_consistency#Arc_consistency). I would >>> appreciate any comments regarding style, what I'm doing wrong in J or how >>> to improve the code. I also have a couple of questions of my own: >>> >>> 1) how do I avoid @ especially once we remove explicit arguments? >>> 2) how do I avoid constant boxing/unboxing due to fill (see arcsX)? >>> 3) Is a boxed value always a pointer? One could imagine implementing >>> 'ragged' arrays without pointers. >>> 4) Is there a good way to have named variables (ie. avoid getx, gety)? >>> 5) Why is a hook the default and not composition? >>> >>> Code at: http://pastebin.com/k4XuKfFi >>> >>> Cheers! >>> >>> Mike >>> ---------------------------------------------------------------------- >>> For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm