> 2010/9/5 gary ng <[email protected]> > > > Hi, > > > > What would be the recommended way to do this , say replace every > > element that is odd to '_1' ? > > > > 0 1 2 3 4 => 0 _1 2 _1 4 > > > > I tried to under stand the 'm } ' verb but don't know how to generate > > the m based on a predicate. > > > > similarly how about replace the first n with _1 ?
Here is another m} version: ]m=: 2 | i.5 0 1 0 1 0 (i.5),: _1 0 1 2 3 4 _1 _1 _1 _1 _1 m} (i.5),: _1 0 _1 2 _1 4 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
