Not sure what your match is, but a potential inefficiency is appending boxed array repeatedly being quadratic, better replacing it by appending integers that can be done in-place. eg.
  xs =: xs, _1, x

and obtain the final boxed array by
  <;._1 xs

Saunders, John (TQEH) wrote:
Hi guys I'm using the below loop to match 2 lists of numbers it
generates a boxed list of the index of matches,(the nth item in the
boxed list xs contains the index of the matches in x of the nth item of
y) there can be multiple matches or none; the lists contain around
30,000 items and this will increase so it's slow and I'm sure its not a
good way to do it could anyone please suggest improved methods.
match =: 3 : 0
for. y do.
index =: index + 1
if. index = #y do. break. end.
x =: (I. ( dex { y) E. ,x) xs =: xs,(<x) end.
)

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



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

Reply via email to