This is curious. ts 'text +/@= LF' 1.55082 2.09894e6 ts 'text +/@:= LF' 0.00420696 1472 ts '+/text=LF' 0.00619269 2.09837e6
Looking at the memory required for the second timing it appears that the equal and the sum are pipelined together as, according to the dictionary, how @ works, not @:, that is, each comparison is added to the sum before it compares the next character. And the first test seems to perform the entire equals test building a list of zeros and ones then summing them which as, according to the dictionary, how @: works. And the third is so much faster than the first timing. On 6/24/07, Roger Hui <[EMAIL PROTECTED]> wrote:
text=: 1!:1 <'\j601\j.dll' $text 1314816 +/text=LF 3393 text +/@:= LF 3393 ts=: 6!:2 , 7!:[EMAIL PROTECTED] ts '+/text=LF' 0.0078334 2.09837e6 ts 'text +/@:= LF' 0.00239304 1472 ----- Original Message ----- From: Joey K Tuttle <[EMAIL PROTECTED]> Date: Sunday, June 24, 2007 7:20 am Subject: Re: Array vs. Looping examples [was Re: [Jgeneral] J Primer - naive implementation of add 2 lists of numbers] > At 07:46 -0400 2007/06/24, Terrence Brannon wrote: > >On 6/20/07, Devon McCormick <[EMAIL PROTECTED]> wrote: > > > >> > >>I am now working on a paper for APL2007 in which I hope to > provide examples > >>of the clarity loopless > >>programming provides compared to the more conventional variety - > > > >Here's one from Ch. 4 of "Learning J" - > > > >+/ text = LF NB. count the linefeeds in the string > > > >It's amazing how close that is to english: > > > >+/ NB. add up > >text = LF NB. the places where text is linefeed > > > >Staggering. > > > > Time to attach an mp3 with the refrain from "My Fair Lady" - > but we'll have to do with the written verse... > > Eliza: The rain in Spain stays mainly in the plain. > Higgins: I think she's got it. I think she's got it. > Eliza: The rain in Spain stays mainly in the plain. > Higgins: By George, she's got it. By George, she's got it. Now > once > again, where does it rain? > Eliza: On the plain! On the plain! > Higgins: And where's that soggy plain? > Eliza: In Spain! In Spain! > Chorus: The rain in Spain stays mainly in the plain!... ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
