I'll typically use "every" when I'm applying a function to items of a boxed array but want an unboxed result. The most common use of this for me is probably checking for empty rows (or columns) and removing them, e.g.
]mat=. a:,~3#,:5$'hi';'';'ho' +--++--+--++ |hi||ho|hi|| +--++--+--++ |hi||ho|hi|| +--++--+--++ |hi||ho|hi|| +--++--+--++ | || | || +--++--+--++ 0+./ . ~:#&>mat 1 0 1 1 0 ]mat=. mat#"1~0+./ . ~:#&>mat NB. Remove empty columns +--+--+--+ |hi|ho|hi| +--+--+--+ |hi|ho|hi| +--+--+--+ |hi|ho|hi| +--+--+--+ | | | | +--+--+--+ ]mat=. mat#~0+./ . ~:"1 #&>mat NB. Remove empty rows +--+--+--+ |hi|ho|hi| +--+--+--+ |hi|ho|hi| +--+--+--+ |hi|ho|hi| +--+--+--+ On 6/12/08, Richard Donovan <[EMAIL PROTECTED]> wrote: > > > While &> *does* have the effect of unboxing, it's use in generic "every" > suggests to me that it's primary > use here is just to set the ranks of the preceding verb to 0 0 0, which are > the ranks of unbox. I > suppose unbox was chosen not only because it's ranks are 0 0 0 but also > because it works on both > boxed AND unboxed data, so making it suitable for the common adverb > "every". > > The fact that "every" takes 9x more time and 2x more space than "0 makes me > wonder if a different (more > efficient?) verb with ranks 0 0 0 could be used in the "every" adverb?) I > can't find any reference to the "every" > adverb in any of the documentation) > > > From: [EMAIL PROTECTED] > > To: [email protected] > > Subject: RE: [Jprogramming] "every" adverb > > Date: Thu, 12 Jun 2008 10:24:54 -0400 > > > > > The purpose of &> is to unbox atoms of the operands. If you don't > > need to do that, "0 is better. > > > > In contrast, u&.> was better than <@u"0 even for unboxed > > operands, last I looked. > > > > Henry Rich > > > > > -----Original Message----- > > > From: [EMAIL PROTECTED] > > > [mailto:[EMAIL PROTECTED] On Behalf Of > > > Richard Donovan > > > Sent: Thursday, June 12, 2008 9:53 AM > > > To: Programming forum > > > Subject: [Jprogramming] "every" adverb > > > > > > > > > I have been playing around with the adverb "every" supplied > > > with the system: > > > > > > d=:i.10 > > > < d > > > --------------------┐ > > > │0 1 2 3 4 5 6 7 8 9│ > > > L-------------------- > > > every > > > &> > > > < &> d > > > --T-T-T-T-T-T-T-T-T-┐ > > > │0│1│2│3│4│5│6│7│8│9│ > > > L-+-+-+-+-+-+-+-+-+-- > > > < "0 d > > > --T-T-T-T-T-T-T-T-T-┐ > > > │0│1│2│3│4│5│6│7│8│9│ > > > L-+-+-+-+-+-+-+-+-+-- > > > d=:i.1e5 > > > (< &> d) -: (< "0 d) > > > 1 > > > ts > > > 6!:2 , 7!:[EMAIL PROTECTED] > > > > > > 10 ts '< &> d' > > > 0.426803 1.50782e7 > > > 10 ts '< "0 d' > > > 0.0517512 7.33485e6 > > > > > > > > > It seems that "every" forces the preceding verb to take on > > > the ranks of verb> (open) > > > i.e. 0 0 0 > > > > > > As you can see from the ts tests I ran, it seems that "every > > > &>" makes a serious time > > > difference to the expression, and also uses more space. > > > > > > If the only purpose of &> is to force the verb ranks to be 0 > > > 0 0 why not just use the > > > expression v "0 which is not only more obvious as to what > > > it's doing but also seems > > > much quicker and leaner? > > > _________________________________________________________________ > > > Great deals on almost anything at eBay.co.uk. Search, bid, > > > find and win on eBay today! > > > http://clk.atdmt.com/UKM/go/msnnkmgl0010000004ukm/direct/01/-- > > > -------------------------------------------------------------------- > > > For information about J forums see > > > http://www.jsoftware.com/forums.htm > > > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > _________________________________________________________________ > Great deals on almost anything at eBay.co.uk. Search, bid, find and win on > eBay today! > > http://clk.atdmt.com/UKM/go/msnnkmgl0010000004ukm/direct/01/---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Devon McCormick, CFA ^me^ at acm. org is my preferred e-mail
---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
