I tried to grasp your intention by (](;,.)ix01icolon > ix10idot) #: i. 2^5
and concluded you want all vectors where at least two 1's are separated by at least one 0. This is also achieved by (1+./@:< [:}:#;.1~)"1 (( 1+./@:< [:}:#;.1~)"1 ,: ix01icolon > ix10idot) #: i. 2^5 0 0 0 0 0 1 0 0 0 1 1 1 0 1 0 0 0 1 1 1 1 1 1 1 0 1 1 1 0 1 0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 1 0 0 0 1 1 1 1 1 1 1 0 1 1 1 0 1 0 0 R.E. Boss > -----Oorspronkelijk bericht----- > Van: [EMAIL PROTECTED] [mailto:programming- > [EMAIL PROTECTED] Namens Tracy Harms > Verzonden: donderdag 20 december 2007 14:38 > Aan: [email protected] > Onderwerp: [Jprogramming] nonsequential 1s > > > The following code works, and solves the following problem: identify > the items in a boolean table that contain non-contiguous ones. > > negateHits=: * (-. + -) > ix10idot =: 1 i."1~ 1 0 E."1 ] > ix01icolon=: (] negateHits (] = {:@[EMAIL PROTECTED])) (1 i:"1~ 0 1 E."1 ]) > b=: #: i. 2^3 > (ix01icolon > ix10idot) b > 0 0 0 0 0 1 0 0 > > I'm very happy with negateHits, although it does have a data-control > x-y parameter arrangement rather than the preferred control-data > arrangement. > > The two index-making definitions are closer than they look. The > index-of-first-occurrences doesn't need to have the extra code because of > the > directionality of greater-than in the final line. > > It seems to me that the next pass here, if this were to be refined, > might be to create a conjunction that would take the bit pattern (1 0 or > 0 > 1) and the associated verb (i. or i:) then produce a verb. I don't > think it is worth doing for this problem, but perhaps my skill is > limiting > my vision. > > Also, if I missed a technique of solving this problem more simply than > I have, I'd like to know. Thank you, in advance, for any comment! > > > Tracy > > > > > __________________________________________________________________________ > __________ > Be a better friend, newshound, and > know-it-all with Yahoo! Mobile. Try it now. > http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
