I should also note that " (explicit or implicit) can also fill the role of boxes in many cases, as exemplified by the earlier <@m"0. Imagine replacing the < with the post-processing verb you intend to apply to its output, and which kind of verbs would work, and which wouldn't (with particular respect to verb rank and output shape).
-Dan Please excuse typos; composed on a handheld device. -----Original Message----- From: "Dan Bron" <[email protected]> Sender: [email protected] Date: Tue, 7 Sep 2010 21:21:17 To: J Programming<[email protected]> Reply-To: Programming forum <[email protected]> Subject: Re: [Jprogramming] Collecting Results No. Or, at least not in general without sneaky, brittle tricks with $. or returning to the grade algebra (/:^:2 etc) of APL<2. Both can be amusing pastimes, trying to find expressions eliding boxes (if you like, I can dig up some references later), but both are (a) harder to maintain and (b) likely to be slower than the original boxy expression, anyway. When you think of ragged arrays (lists with non-uniformly-shaped items), think of boxes. Just like when you think of heterogeneous arrays (lists with non-uniform types, eg char ; num) you think of boxes. In fact, to J, "differently shaped" is just another kind of "heterogeneous". So, semantically, boxes are what you want. Best practice in any prog. lang. is "try saying what you mean first, then empirically measure performance relative to thresholds. If the 'obvious' expression is too slow, only then try to optimize". That applies to J as well, though I would add an intermediate step "... complain on the Forums and see what answers you get first, ...". At the very least, you may inspire improvements in the interpreter which everyone will benefit from. Sometimes surprisingly (alarmingly) fast. -Dan Please excuse typos; composed on a handheld device. -----Original Message----- From: Justin Paston-Cooper <[email protected]> Sender: [email protected] Date: Tue, 7 Sep 2010 21:47:30 To: Programming forum<[email protected]> Reply-To: Programming forum <[email protected]> Subject: Re: [Jprogramming] Collecting Results Thanks a lot. I always forget about boxed lists. Applying ; to that gives exactly what I want. Is there any way to do it without boxing, though? This will be applied many times and I don't know how efficient this will be. On 7 September 2010 21:32, Dan Bron <[email protected]> wrote: > You want m&.> f . Note this is rank 0 already, so no reason for an > explicit"0 . > > I'm on the road right now so I can't post a fuller explanation, but it might > be understandable if you're told that <@m"0 f is equivalent, and that > is > both scalar (rank zero) and an identity function on an open (non-boxed) noun. > > -Dan > > > > > Please excuse typos; composed on a handheld device. > > -----Original Message----- > From: Justin Paston-Cooper <[email protected]> > Sender: [email protected] > Date: Tue, 7 Sep 2010 21:09:37 > To: <[email protected]> > Reply-To: Programming forum <[email protected]> > Subject: [Jprogramming] Collecting Results > > Hello, > > Let's say I have a monad m " 0 and a 1-dimensional array f. The monad > returns 1-dimensional arrays of varying results which may include 0. I > would like to efficiently apply the monad m to array f and collect the > results returned by m in a 1-dimensional array. m f would not be > satisfactory because 0s may be added to the ends of the results which > are shorter than the longest result. Is this possible? Thanks for your > advice in advance. > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
