as I understand it, special code is a bit picky in how it is found. For instance:
<. % y is not sped up, while <.@% y is. AFAIU, the rule is whether it is a single verb phrase. Trains count as such a single verb phrase. so smoutput could well interfere with special code finding. Though, the example I gave does not appear to be any faster than this: timespacex '>./ (#~ ( -: |.)@":"0) \:~ ~. , */~ 100+i.900' 0.0988705 3.56739e7 Your technique for short circuits could be a good candidate for special code. ----- Original Message ----- From: David Lambert <[email protected]> To: programming <[email protected]> Cc: Sent: Monday, June 9, 2014 9:21:44 AM Subject: Re: [Jprogramming] Project Euler Question 4 Thank you. I'll reread the special code optimizations section. When I insert my favorite side effect hook ([smoutput), emacs tells me that j did all the computations. It did not stop at finding the first matching index. #~. , */~ 100+i.900 227521 ({~ (-: |.)@([smoutput)@":"0 i. 1:) \:~ ~. , */~ 100+i.900 ...Region has 227520 lines, 227520 words,... 906609 >Date: Sun, 8 Jun 2014 20:25:01 -0700 (PDT) >From: "'Pascal Jasmin' via Programming" <[email protected]> >To: "[email protected]" <[email protected]> >Subject: Re: [Jprogramming] Project Euler Question 4 >Message-ID: > <[email protected]> >Content-Type: text/plain; charset=iso-8859-1 > timespacex '(* (-: |.)@":)@:[^:(0=])/ 0,~ /:~ ~. , */~ 100+i.900' >0.167316 3.56726e7 > >btw, there is an optimization close to short circuiting built in: > > ({~ (-: |.)@":"0 i. 1:) \:~ ~. , */~ 100+i.900 >906609 > > timespacex '({~ (-: |.)@":"0 i. 1:) \:~ ~. , */~ 100+i.900' ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
