Raul's method of reducing the replacement problem
into simple arithmetic is a classic.
rpl2=: ] - (0 ,~ -/)@[ {~ ] i.~ [EMAIL PROTECTED]
It'd be nice to know when he first used it
.
I've not seen it before so I thought I'd offer an
explicit form to help others appreciate its
elegance and simplicity.
repl3 =: 4 : 0
'a b' =. x
y +((>:#a){.b-a){~ a i.y
)
Create an array of shape $y with elements that are the difference
between the new and old values and then add it to the original arrays.
For values in y that should remain unchanged, add zero.
Marvelous.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm