x=: 20 [EMAIL PROTECTED] 20
y=: 10 [EMAIL PROTECTED] 10
((~.x) i. y) { (x </.i.#x),a:
+----+++--+++------++------++
|0 10|||19|||6 8 17||6 8 17||
+----+++--+++------++------++
x=: 1e6 [EMAIL PROTECTED] 1e5
y=: 2e5 [EMAIL PROTECTED] 1e5
ts=: 6!:2 , 7!:[EMAIL PROTECTED]
ts '((~.x) i. y) { (x </.i.#x),a:'
0.644278 2.12919e7
----- Original Message -----
From: Joey K Tuttle <[EMAIL PROTECTED]>
Date: Monday, April 2, 2007 10:43 pm
Subject: Re: [Jprogramming] Replace slow loop
> I am unclear on what you are trying to do. If I understand
> your description then I wonder, does the following define
> what you want?
>
> ]x =. ?. 20$20
> 6 15 19 12 14 19 0 17 0 14 6 18 13 18 11 12 18 0 10 2
>
> ]y =. ?. 10$10
> 6 5 9 2 4 9 0 7 0 4
>
> <@I. y =/ x
> +----+++--+++------++------++
> |0 10|||19|||6 8 17||6 8 17||
> +----+++--+++------++------++
>
> If so, then the question is how to make it work with large
> x and y vectors.
>
> - joey
>
> At 11:50 +0930 2007/04/03, 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