[Jprogramming] Re: Replacement
david alis
david.alis at gmail.com
Fri Jul 6 02:24:39 HKT 2007
Raul's method of reducing the replacement problem
into simple arithmetic is a classic.
rpl2=: ] - (0 ,~ -/)@[ {~ ] i.~ {.@[
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.
More information about the Programming
mailing list