Here's an idea, untested since I'm on my phone.
Get the indices of the numbers and blanks.
NB. A is the array with blanks.
N=. I. _ ~: A
B=. I. _ = A
For each item in B takes absolute difference from the items in N.
D=. ¦B -"0 1 N
The indices of the mins are are the ones you want from N which are the
indices you want from A.
X=. A {~N {~(i. <./)"1 D
Now use amend.
X B} A
Ken I know you work with huge datasets, keep in mind that this is
inneficient since it doesn't use the fact that the array is sorted and
always computes all the differences, i.e., D can become huge. Though you
should probably combine the difference and min steps.
Hope it helps.
On Sep 28, 2011 10:45 PM, "Lettow, Kenneth" <[email protected]> wrote:
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm