@Raul Miller Sorry about the typo.
It's pretty late now. Will revisit your message in the morning. On Sun, Jun 4, 2017 at 12:19 PM, Raul Miller <[email protected]> wrote: > > For example, what's the difference between > > > > 2 3 <@, 3 4 and 1 2 <@:, 3 4 > > > > when the result is the same? > > Well... the result is not the same here, because 2 3 is different from 1 2. > > That said, <@, produces the same result as <@:, for the same > arguments. The difference between @ and @: would only matter if the > rank of an argument exceeded the rank of the right verb, and that > cannot happen when , is the right verb. > > As for > (#~ 5=2#.@:|])z > 3 4 5 > > It would probably be slightly easier to explain with this rephrasing: > > (#~ 5=2#.2|])z > 3 4 5 > > The first thing to note is: > > 2 | z > 0 1 0 > 1 0 1 > > This sort of result is related to the result you get from z { 1 0 1 0 1 0 > > z { 1 0 1 0 1 0 > 1 0 1 > 0 1 0 > 1 - 2 | z > 1 0 1 > 0 1 0 > > The next step, if we are evaluating things in the same order J > evaluates, we have: > > 2 #. 2 | z > 2 5 > > In other words, each row from our result is now encoded as an integer > (we treat the individual values as bits). > > 5, in this case corresponds to 1 0 1 as the result of 2 | z which in > turn corresponds to 0 1 0 as the result of 1-2|z > > This sort of rephrasing might get a more involved if we started to get > into variable width values for z, but it's not yet clear to me if that > becomes necessary, nor what the patterns would be like if we went > there. > > Hopefully that makes sense? > > Thanks, > > -- > Raul > > On Sun, Jun 4, 2017 at 11:30 AM, Michael Rice <[email protected]> wrote: > > Two things come to mind: 1) *reductio ad absurdum* and 2) a Dustin > Hoffman > > film, wherein he says to a man, "I going to explain something so you'll > > understand it!" and then shoots him. > > > > I already had a function that does what I needed (see below) but was > musing > > about left/right parameter style, when one of the parameters remains > > constant and the other changes "functionally" in the program. > > > > Just looking at your first "simplification," I can see I have a lot of > > familiarization work to do. For example, what's the difference between > > > > 2 3 <@, 3 4 and 1 2 <@:, 3 4 > > > > when the result is the same? > > > > Must be something subtle. > > > > ================= > > > > Note: The moves marked with "<-" are moves to a known solution. > > > > > > NB. 15 position peg solitaire > > NB. The board (position 5 initially vacant) > > > > NB. 0 > > NB. 1 2 > > NB. 3 4 5 > > NB. 6 7 8 9 > > NB. 10 11 12 13 14 > > > > move_table =: 36 3 $ 0 2 5 5 2 0 0 1 3 3 1 0 1 3 6 6 3 1 1 4 8 8 4 1 > 2 4 > > 7 7 4 2 2 5 9 9 5 2 3 6 10 10 6 3 3 7 12 12 7 3 3 4 5 5 4 3 4 7 11 11 7 > 4 4 > > 8 13 13 8 4 5 8 12 12 8 5 5 9 14 14 9 5 6 7 8 8 7 6 7 8 9 9 8 7 10 11 12 > 12 > > 11 10 11 12 13 13 12 11 12 13 14 14 13 12 > > id =: e. i. 15 > > flip =: (~: 3 : 'if. ((< & 2) @: #) y do. ({ & id) y else. (+./ @: ({ > & > > id)) y end. ') > > legal_moves =: (#~ ((-: & 1 1 0)"1 @: ({~ & move_table))) > > board =: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 > > board > > 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 > > board =: board flip 5 > > board > > 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 > > move_table legal_moves board > > 0 2 5 <- > > 3 4 5 > > 12 8 5 > > 14 9 5 > > board =: board flip 0 2 5 > > board > > 0 1 0 1 1 1 1 1 1 1 1 1 1 1 1 > > move_table legal_moves board > > 3 1 0 <- > > 7 4 2 > > 9 5 2 > > board =: board flip 3 1 0 > > board > > 1 0 0 0 1 1 1 1 1 1 1 1 1 1 1 > > move_table legal_moves board > > 8 4 1 > > 7 4 2 > > 9 5 2 > > 10 6 3 > > 12 7 3 > > 5 4 3 <- > > board =: board flip 5 4 3 > > board > > 1 0 0 1 0 0 1 1 1 1 1 1 1 1 1 > > move_table legal_moves board > > 6 3 1 <- > > 11 7 4 > > 13 8 4 > > 12 8 5 > > 14 9 5 > > board =: board flip 6 3 1 > > board > > 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 > > move_table legal_moves board > > 0 1 3 <- > > 12 7 3 > > 11 7 4 > > 13 8 4 > > 12 8 5 > > 14 9 5 > > 8 7 6 > > board =: board flip 0 1 3 > > board > > 0 0 0 1 0 0 0 1 1 1 1 1 1 1 1 > > move_table legal_moves board > > 11 7 4 <- > > 13 8 4 > > 12 8 5 > > 14 9 5 > > 8 7 6 > > board =: board flip 11 7 4 > > board > > 0 0 0 1 1 0 0 0 1 1 1 0 1 1 1 > > move_table legal_moves board > > 8 4 1 > > 3 4 5 <- > > 12 8 5 > > 14 9 5 > > 9 8 7 > > 13 12 11 > > board =: board flip 3 4 5 > > board > > 0 0 0 0 0 1 0 0 1 1 1 0 1 1 1 > > move_table legal_moves board > > 9 5 2 <- > > 13 8 4 > > 9 8 7 > > 13 12 11 > > board =: board flip 9 5 2 > > board > > 0 0 1 0 0 0 0 0 1 0 1 0 1 1 1 > > move_table legal_moves board > > 13 8 4 > > 12 8 5 > > 13 12 11 <- > > board =: board flip 13 12 11 > > board > > 0 0 1 0 0 0 0 0 1 0 1 1 0 0 1 > > move_table legal_moves board > > 10 11 12 <- > > board =: board flip 10 11 12 > > board > > 0 0 1 0 0 0 0 0 1 0 0 0 1 0 1 > > move_table legal_moves board > > 12 8 5 <- > > board =: board flip 12 8 5 > > board > > 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 > > move_table legal_moves board > > 5 2 0 > > 2 5 9 <- > > board =: board flip 2 5 9 > > board > > 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 > > move_table legal_moves board > > 14 9 5 <- > > board =: board flip 14 9 5 > > board > > 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 > > move_table legal_moves board > > > > > > > > > > On Sun, Jun 4, 2017 at 10:03 AM, Raul Miller <[email protected]> > wrote: > > > >> Like this? > >> > >> (#~ 5=2#.@:|])z > >> 3 4 5 > >> > >> -- > >> Raul > >> > >> > >> On Sun, Jun 4, 2017 at 9:43 AM, Michael Rice <[email protected]> > wrote: > >> > How about > >> > 1 0 1 0 1 0 (#~ ((-: & 0 1 0)"1 @: ({~ & z)))~ z > >> > ? > >> > > >> > Odd, that's the KISS way, the way that always works, and the one way I > >> > hadn't considered. > >> > > >> > On to your "simplifications." > >> > > >> > On Sat, Jun 3, 2017 at 10:16 PM, Louis de Forcrand <[email protected]> > >> wrote: > >> > > >> >> How about > >> >> 1 0 1 0 1 0 (#~ ((-: & 0 1 0)"1 @: ({~ & z)))~ z > >> >> ? > >> >> You can then "simplify": > >> >> > >> >> First the hook (and {~&z) > >> >> ([ #~ -:&0 1 0"1@:(z&{)@])~ > >> >> ([ #~ -:&0 1 0"1@:(z&{)@])~ > >> >> > >> >> Then ~ can be "distributed" over the resulting fork: > >> >> [~ #~ -:&0 1 0"1@:(z&{)@(]~) > >> >> ] #~ -:&0 1 0"1@:(z&{)@[ > >> >> > >> >> You can keep going; > >> >> From bonding to forks: > >> >> ] #~ (] -: 0 1 0"_)"1@:(z { ])@[ > >> >> Composition and -: commutativity: > >> >> ] #~ (0 1 0 -: ])"1@:(z { ]@[) > >> >> Because 1=#$0 1 0: > >> >> ] #~ (0 1 0 -:"1 ])@:(z { [) > >> >> Trains: > >> >> ] #~ (0 1 0 -:"1 ]@:(z { [)) > >> >> ] #~ 0 1 0 -:"1 ]@:(z { ]) > >> >> ] #~ 0 1 0 -:"1 z { [ > >> >> > >> >> Can't get it any simpler. > >> >> > >> >> Cheers, > >> >> Louis > >> >> > >> >> > On 4 Jun 2017, at 03:45, Michael Rice <[email protected]> wrote: > >> >> > > >> >> > z (#~ ((-: & 0 1 0)"1 @: ({~ & z))) 1 0 1 0 1 0 > >> >> > >> >> ------------------------------------------------------------ > ---------- > >> >> 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 > >> > > ---------------------------------------------------------------------- > > 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
