Thanks.

I haven't heard of paste & match - I like to use Thunderbird to support the sharewarers, but fight against some of its features. With time & patience, I copy & paste into a notepad file, and then re-copy and paste into T/bird. I hadn't bothered in my recent posts. I do (and did in this case) indent and insert whitespace, albeit by hand rather than using
any formatter that J might have to hand.

I see "because copulas are special" but don't quite see why avoiding the space helps.

Yes - if I'm really worried about performance, I do similar tweaks on loop input. Is a while
loop better in this case?  (I haven't time to check that now.)

Anyway, I've got to practise a bit of music and then go out for the evening, so enough
from me for now.

Breakfast tomorrow is another day,

Mike



On 25/06/2017 18:36, Raul Miller wrote:
Not quite, I have a few trivial tweaks that I think make reading it a
bit easier.

(1) I used "Paste and match style" rather than simply paste, when
inserting the code into my message, to eliminate the blank lines that
some insane programming teams decided should be inserted when using
paste.

(2) I indented the code to reflect the explicit structures.

(3) I commuted a multiplication to better show similarity with a
multiplication on the line above.

(4) I ate the whitespace to the left of copulas, because copulas are special.

These are, granted, issues of taste, which means there will always be
someone with different views. They do not help0 performance nor reduce
resource costs in any way. Nevertheless, these reflect my views.

And, (5) a nearly invisible performance improvement (eliminate one
operation) when setting up the loop.

Now... if I could just get my mailer to display messages using a fixed
width font...

finalrev=: 3 : 0    NB.  good name?
   m=. >./y
   for_i. 2+i.<:n=. #y do.
     m=. m >. i * q=. >./ y =. 2 <./\ y
     if. m >: n * q do. break. end.
   end.
)

I am not certain though if my (5) hurts readability, but for code like
this you sort of need to go in and see the data to really understand
it. So, here's an instrumented version - I would recommend only trying
this on small arguments (and the displayed result is meant to be used
to help understand the uninstrumented version):

show=: 1 {:: 1!:2&2@(] :(,~))
showfinalrev=: 3 : 0
   show 'y';y
   show 'm';m=. >./y
   for_i. 2+i.<: show 'n';n=. #y do.
     ('q';q;'y';y) show 'm';m=. m >. i * q=. >./ y =. 2 <./\ y
     if. show 'break';m >: n * q do. break. end.
   end.
)

That said, thank you for the excellent treatment of this problem. You
took this a lot further than I had.

Thanks,



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

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

Reply via email to