This is nice. I would package it as:
validalt=: 1 = [: (>./-<./) [: +/\ 1 _1 +/ .* ] Thanks, -- Raul On Sat, Jul 28, 2012 at 7:12 AM, R.E. Boss <[email protected]> wrote: > My 2 cents: > > (>./-<./)+/\+/1 _1 *A > 1 > > (>./-<./)+/\+/1 _1 *B > 2 > > So A qualifies, B does not. > > > R.E. Boss > > >> -----Oorspronkelijk bericht----- >> Van: [email protected] >> [mailto:[email protected]] Namens Linda Alvord >> Verzonden: zaterdag 28 juli 2012 9:43 >> Aan: [email protected] >> Onderwerp: Re: [Jprogramming] Determining an 'alternating' binary array >> >> In this case the tacit version leads to a better explicit definition: >> >> >> al=: 13 :'(-:((2 2$0 1 1 0)$~#))(|: y) -. 0 0' >> al >> [: (-: ((2 2$0 1 1 0) $~ #)) 0 0 -.~ |: >> >> al2=: 13 :'(-:(2 2$0 1 1 0)$~#)0 0 -.~|:y' >> al2 >> [: (-: ((2 2$0 1 1 0) $~ #)) 0 0 -.~ |: >> >> Linda >> >> -----Original Message----- >> From: [email protected] >> [mailto:[email protected]] On Behalf Of Linda Alvord >> Sent: Saturday, July 28, 2012 3:14 AM >> To: [email protected] >> Subject: Re: [Jprogramming] Determining an 'alternating' binary array >> >> This seems to work as well: >> >> (|:A)-: |: A/:A >> 1 >> al=: 13 :'(-:((2 2$0 1 1 0)$~#))(|: y) -. 0 0' >> al >> [: (-: ((2 2$0 1 1 0) $~ #)) 0 0 -.~ |: >> >> al A >> 1 >> al B >> >> -----Original Message----- >> From: [email protected] >> [mailto:[email protected]] On Behalf Of Linda Alvord >> Sent: Saturday, July 28, 2012 2:45 AM >> To: [email protected] >> Subject: Re: [Jprogramming] Determining an 'alternating' binary array >> >> Here's an alternative to 'alternative' >> >> ]A=:2 8$ 0 0 1 0 0 0 0 1 1 0 0 0 1 0 0 0 >> 0 0 1 0 0 0 0 1 >> 1 0 0 0 1 0 0 0 >> ]B=:2 5$1 0 0 0 1 0 1 1 0 0 >> 1 0 0 0 1 >> 0 1 1 0 0 >> alt=: 13 :'(-:((2 2$0 1 1 0)$~#))(|: y /:y) -. 0 0' >> alt >> [: (-: ((2 2$0 1 1 0) $~ #)) 0 0 -.~ [: |: /:~ >> >> alt A >> 1 >> alt B >> 0 >> >> Linda >> >> -----Original Message----- >> From: [email protected] >> [mailto:[email protected]] On Behalf Of Marshall >> Lochbaum >> Sent: Friday, July 27, 2012 11:56 AM >> To: [email protected] >> Subject: Re: [Jprogramming] Determining an 'alternating' binary array >> >> Here's another option: convert the two rows into one using base 2, discard >> the ones that are 0, and check if the remaining ones are 1 2 1... >> I borrowed the sort in Raul's solution so that they must be in that order, >> not 2 1 2... . >> >> alternate =: (-: 1 2$~$)@:(0 -.~ #.@|:)@:/:~ >> >> Note that we don't have to convert to binary. In this case, we end up with >> >> alternate =: (-: (0 1,:1 0)$~#)@:(0 0 -.~ |:)@:/:~ >> >> Marshall >> >> On Fri, Jul 27, 2012 at 10:39 AM, Brian Schott >> <[email protected]>wrote: >> >> > Another approach? >> > >> > alternates =: [: -. 1 e. [: +/ 0 1 |."0 1 ] #"_ 1~ +./ noAnds =: >> > *./@(-.@(*./)) check =: noAnds *. alternates >> > >> > >> > >> > >> > -- >> > (B=) >> > ---------------------------------------------------------------------- >> > 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 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
