> From: "Sherlock, Ric" <[EMAIL PROTECTED]>

> 
> ---Raul Miller wrote:
> > Was there anything wrong with my definition for join?
> >    join=: [EMAIL PROTECTED] }. [:;,L:0
> 
> It's nice and simple,
>      join03=: [EMAIL PROTECTED] }. [:;,&.>
> Is perhaps slightly clearer and a little faster, but doesn't handle left args 
> of 
> length >1.
> join04 / join05 seem to have the best combination of performance and 
> features, 
> but are not as simple or easy to understand.
> 
> a=: '-'
> b=: 100000 [EMAIL PROTECTED] 8
> c=: (b&(<@{."0 _)) 'abcdefghi'
> 
> ts=: 6!:2 , 7!:[EMAIL PROTECTED]
> 
> join01=: [: ; [EMAIL PROTECTED] , [: , [EMAIL PROTECTED] ,. [EMAIL PROTECTED]
> 
> join02=: [EMAIL PROTECTED] }. [:;,L:0
> join03=: [EMAIL PROTECTED] }. [:;,&.>  NB. Use each instead of L:0
> 
> join04=: ' '&$. :(4 : '(;@(#^:_1!.(
> join05=: 3 : 0  NB. Explicit version of join04
>   ' ' join04 y
>   :
>   (;@(#^:_1!.(
> )
> 
>      50{.a join01 c
> ab-abcd-abcd-abc-ab--ab-abcde-abcde--abc-a-abcd--a
> 
>      *./(
> 1
> 
>      20 ts 'a join01 c'
> 0.143952 2.91738e6
> 
>      20 ts 'a join02 c'
> 0.0392969 7.8592e6
> 
>      20 ts 'a join03 c'
> 0.0339473 7.85914e6
> 
>      20 ts 'a join04 c'
> 0.0361777 1.83859e6
> 
>      20 ts 'a join05 c'
> 0.0353627 1.83859e6

Here's one that is similar in time and space to 04 and 05,
but is very simple to understand.

join08=: [EMAIL PROTECTED] }. [EMAIL PROTECTED] ;@,. ]

   20 ts 'a join08 c'
0.0295858 1.98349e6

   20 ts 'a join05 c'
0.0272022 1.83859e6


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

Reply via email to