osdir.com
mailing list archive
Mozy Online Backup: 2GB Free. Automatic. Secure.

Subject: Re: Array vs. Looping examples [was Re: J Primer - naive implementation of add 2 lists of numbers] - msg#00290

List: lang.j.general

Date: Prev Next Index Thread: Prev Next Index
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 <rhui000-fVOoFLC7IWo@xxxxxxxxxxxxxxxx> wrote:

text=: 1!:1 <'\j601\j.dll'
$text
1314816
+/text=LF
3393
text +/@:= LF
3393

ts=: 6!:2 , 7!:2@]
ts '+/text=LF'
0.0078334 2.09837e6
ts 'text +/@:= LF'
0.00239304 1472



----- Original Message -----
From: Joey K Tuttle <jkt-2rm9UrUe0KQ@xxxxxxxxxxxxxxxx>
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
<devonmcc-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx> 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




Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: Learning J - chapter assessment tests

On 6/23/07, Terrence Brannon <metaperl.j-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx> wrote: oh, yes, well this is chapter 1 and Bond has not been introduced yet. Nor has Atop. So pretty much any new reader will only choose >: 7 This seems to imply an approach very different from that recommended by the primer: http://www.jsoftware.com/help/primer/how_to_use.htm (I realised this after noticing a pertinent KEI quote: http://keiapl.info/anec/#exercise and then trying to find if that had been incorporated in the primer.) -- Raul

Next Message by Date: click to view message preview

Re: Array vs. Looping examples [was Re: J Primer - naive implementation of add 2 lists of numbers]

Oh, I see what's happening in the @ timing. It was as the dictionary said. It was including only one number in each of the sums. (~.;#)text +/@= LF +---+-------+ |0 1|1314816| +---+-------+

Previous Message by Thread: click to view message preview

Re: Array vs. Looping examples [was Re: J Primer - naive implementation of add 2 lists of numbers]

text=: 1!:1 <'\j601\j.dll' $text 1314816 +/text=LF 3393 text +/@:= LF 3393 ts=: 6!:2 , 7!:2@] ts '+/text=LF' 0.0078334 2.09837e6 ts 'text +/@:= LF' 0.00239304 1472 ----- Original Message ----- From: Joey K Tuttle <jkt-2rm9UrUe0KQ@xxxxxxxxxxxxxxxx> 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 > ><devonmcc-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx> 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!...

Next Message by Thread: click to view message preview

RE: Array vs. Looping examples [was Re: J Primer - naiveimplementation of add 2 lists of numbers]

+/@:= is backed by special code as noted on that page. That special code does indeed pipeline the +/ and the = . Henry Rich > -----Original Message----- > From: general-bounces-eCoxsOKuxbJl57MIdRCFDg@xxxxxxxxxxxxxxxx > [mailto:general-bounces-eCoxsOKuxbJl57MIdRCFDg@xxxxxxxxxxxxxxxx] On Behalf Of > Don Guinn > Sent: Sunday, June 24, 2007 3:30 PM > To: General forum > Subject: Re: Array vs. Looping examples [was Re: [Jgeneral] J > Primer - naiveimplementation of add 2 lists of numbers] > > 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 <rhui000-fVOoFLC7IWo@xxxxxxxxxxxxxxxx> wrote: > > > > text=: 1!:1 <'\j601\j.dll' > > $text > > 1314816 > > +/text=LF > > 3393 > > text +/@:= LF > > 3393 > > > > ts=: 6!:2 , 7!:2@] > > ts '+/text=LF' > > 0.0078334 2.09837e6 > > ts 'text +/@:= LF' > > 0.00239304 1472 > > > > > > > > ----- Original Message ----- > > From: Joey K Tuttle <jkt-2rm9UrUe0KQ@xxxxxxxxxxxxxxxx> > > 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 > > > ><devonmcc-Re5JQEeQqe8AvxtiuMwx3w@xxxxxxxxxxxxxxxx> 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
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by