I prefer the  find`replace}  idiom.  Thus:

           b  -:  =&(<'s1')`(a:&,:)}  a
        1

I have abstracted this to a conjunction which does scalar replacement:

           sr =:  2 : 'm&=`(,:&n)}'
           
Though, because your predicate is exclusive (replace all scalars NOT equal to 
...) as opposed to inclusive, you'd have to use a slightly modified version:

           dsr=:  2 : 'm&=`(n&,:)}'

           b  -:  (<'s1') dsr a: a
        1

I hope this will one day be supported by special code.  And I hope it helps you 
(I haven't taken the time to grok your more detailed requirements).

-Dan

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to