Forget about (2). I was thinking it was an intermediate step to (3) but it doesn't make sense as written.
Henry Rich > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Henry Rich > Sent: Saturday, May 05, 2007 4:51 PM > To: 'Programming forum' > Subject: [Jprogramming] Proposal: unboxing suffix scans > > /\. is such a workhorse in J that some common cases might > be worth special code: > > 0. >@(f&.>/\.) > > Here, if the result of f is small, it would be nice to produce the > unboxed result directly, saving the boxing overhead on the suffix > results. > > 1. m&{.@>@(f&.>/\.) > > This is a potential huge gain. For many scan-type operations, the > intermediate result contains a lot of state that is needed for the > computation of f but is not needed in the final result. In the form > given, the interpreter knows enough to keep each result of f, unboxed, > for the next call to f, and then to discard the items that are not > needed in the final result. This would save not just the boxing > overhead but also the storage of the intermediate vector for each > input item. > > 2. (f&.>/\.)@:(<"n) and variants like 0 and 1 above > > To cause the scan to work on the appropriate cells when they are not > items, the cells must be boxed. The boxing/unboxing could be avoided. > > 3. (f&.>/\.)@:(<"[EMAIL PROTECTED] , <@]) and variants like 0 and 1 above > > A very common case is where the scan is to be applied to an array > with an initial value given. Usually, the initial value has the shape > of a result of f, which is different from the shape of an item of > the array. Then, it is necessary to box everything up, append the > intial value to the end of the array, and perform the scan. > Recognizing > this pattern would save the boxing and the append, which will be a > big gain if the items of the array are small. > > Henry Rich > > > > > ---------------------------------------------------------------------- > For information about J forums see > http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
