...Anyway I can well believe that there's a factor of 1.5 on the PC (if that's what you're using). The iMac has tricks the PC can only dream of.
On Fri, Sep 7, 2012 at 3:07 PM, Ian Clark <[email protected]> wrote: > I'm grateful you did. Had you not done so, I'd have persisted in my > unconscious acceptance of }. being no better or worse than }: . > > On Fri, Sep 7, 2012 at 3:02 PM, Roger Hui <[email protected]> wrote: >>> But there is a difference, and it's reproducible. >> >> The difference is so small that I wouldn't worry about it. I would not >> have posted my msg if I knew that the timings were not reproducible. I >> thought there was a factor of 1.5. >> >> >> >> On Fri, Sep 7, 2012 at 6:37 AM, Ian Clark <[email protected]> wrote: >> >>> The point is well-made, Roger. >>> >>> SP=: ' ' >>> b2o=: }.@((<SP) ;@,. ]) >>> b2q=: }:@((<SP) ;@,.~ ]) >>> >>> x=: (1e6 ?@$ 20) $&.> 'x' >>> $ b2o x >>> 10497510 >>> >>> timer 'b2o x' >>> 0.189877 >>> timer 'b2q x' >>> 0.189789 >>> >>> Counter-intuitive, when I first saw it. But only to be expected, when >>> I thought it through. >>> >>> s=: 1e7 $ 'x' >>> >>> timer '}. s' >>> 0.0148418 >>> timer '}: s' >>> 0.014695 >>> >>> Dropping a char off the end of a string is apt to be cheaper than >>> dropping it off the beginning, because chars will probably need to be >>> shifted across word boundaries. >>> >>> On my Mac there's not a lot of difference in speed (which varies, no >>> doubt due to the varying memory chunks available to malloc). But there >>> is a difference, and it's reproducible. >>> >>> On Fri, Sep 7, 2012 at 6:00 AM, Roger Hui <[email protected]> >>> wrote: >>> > SP=: ' ' >>> > b2o=: }.@((<SP) ;@,. ]) >>> > b2q=: }:@((<SP) ;@,.~ ]) >>> > >>> > x=: (1e6 ?@$ 20) $&.> 'x' >>> > >>> > (b2o -: b2q) x >>> > 1 >>> > >>> > timer 'b2o x' >>> > 0.388007 >>> > timer 'b2q x' >>> > 0.262082 >>> > >>> > >>> > >>> > On Thu, Sep 6, 2012 at 4:07 PM, Ian Clark <[email protected]> wrote: >>> > >>> >> Quite right, Raul. And strings containing newlines do matter to me. A >>> lot. >>> >> >>> >> I confess I only threw in bpv as a bit of a joke. It relies on 5!:5 >>> >> converting boxed z to... >>> >> <;._1 ' alpha bravo charlie' >>> >> which it doesn't always. In fact, it returns your example without change >>> >> ... >>> >> >>> >> z123=: '1';'2';'3' >>> >> 5!:5 <'z123' >>> >> '1';'2';'3' >>> >> >>> >> So I fear bpv doesn't merit close attention. >>> >> >>> >> (I suspect ;:inv will eventually let me down too, but I haven't fooled >>> it >>> >> yet!) >>> >> >>> >> b2o and its sister b2f do matter, however, as I propose to put serious >>> >> weight on them, as g.p. utilities. >>> >> >>> >> b2o=: }.@((<SP) ;@,. ]) >>> >> b2f=: }.@((<LF) ;@,. ]) >>> >> >>> >> so I'd be grateful to be notified of anyone making them misbehave. >>> >> >>> >> Possible gray areas to investigate: use of i{a. where i>127, utf-8, >>> >> boxed scalars, strings with CRLF, 0{a. and other subasciis, uses of a: >>> >> , etc, etc. >>> >> >>> >> On Thu, Sep 6, 2012 at 11:43 PM, Raul Miller <[email protected]> >>> >> wrote: >>> >> > Note that bpv would also have problems with boxed strings containing >>> >> > spaces, and even worse problems with boxed strings containing >>> >> > newlines. (It's not clear, though, if strings containing newlines >>> >> > matter to you.) >>> >> > >>> >> > -- >>> >> > Raul >>> >> > >>> >> > On Thu, Sep 6, 2012 at 6:39 PM, Ian Clark <[email protected]> >>> wrote: >>> >> >> Right you are. >>> >> >> >>> >> >> What I really want (but haven't said) is the fastest versions of b2o >>> >> >> (boxed-to-open-string) and b2f (boxed-to-LF-separated-string), where >>> >> >> b2f is b2o with ' ' (-:SP) replaced with LF. >>> >> >> >>> >> >> I think I've got them now, thanks to everyone. >>> >> >> >>> >> >> BTW solutions involving deb aren't general enough, esp for b2f, where >>> >> >> the boxed strings may validly contain multiple spaces. >>> >> >> >>> >> >> On Thu, Sep 6, 2012 at 11:32 PM, Raul Miller <[email protected]> >>> >> wrote: >>> >> >>> I prefer >>> >> >>> ;:inv z >>> >> >>> >>> >> >>> But note that >>> >> >>> >>> >> >>> deb,' ',.>z >>> >> >>> >>> >> >>> would work. (J6 users need require'strings' before this can work.) >>> >> >>> >>> >> >>> FYI, >>> >> >>> >>> >> >>> -- >>> >> >>> Raul >>> >> >>> >>> >> >>> On Thu, Sep 6, 2012 at 6:21 PM, Ian Clark <[email protected]> >>> >> wrote: >>> >> >>>> Yes, but we need a string. >>> >> >>>> You can ravel the 2D array to get a string, viz: >>> >> >>>> ,> z >>> >> >>>> but it gives you a varying number (0 or more) of separating spaces. >>> >> >>>> >>> >> >>>> On Thu, Sep 6, 2012 at 10:50 PM, km <[email protected]> wrote: >>> >> >>>>> > 'alpha';'bravo';'charlie' >>> >> >>>>> alpha >>> >> >>>>> bravo >>> >> >>>>> charlie >>> >> >>>>> >>> >> >>>>> I'm resending because the echo from Jsoftware to my iPad was >>> >> incorrect. Hope this one shows my solution was to open the list of >>> boxes. >>> >> >>>>> >>> >> >>>>> Sent from my iPad >>> >> >>>>> >>> >> >>>>> >>> >> >>>>> On Sep 6, 2012, at 4:32 PM, km <[email protected]> wrote: >>> >> >>>>> >>> >> >>>>>>> 'alpha';'bravo';'charlie' >>> >> >>>>>> alpha >>> >> >>>>>> bravo >>> >> >>>>>> charlie >>> >> >>>>>> >>> >> >>>>>> (shape 3 7) >>> >> >>>>>> >>> >> >>>>>> Sent from my iPad >>> >> >>>>>> >>> >> >>>>>> >>> >> >>>>>> On Sep 6, 2012, at 11:38 AM, Ian Clark <[email protected]> >>> >> wrote: >>> >> >>>>>> >>> >> >>>>>>> Kindergarten class... >>> >> >>>>>>> >>> >> >>>>>>> I have a list of boxed literals... >>> >> >>>>>>> z=: 'alpha' ; 'bravo' ; 'charlie' >>> >> >>>>>>> >>> >> >>>>>>> I want to flatten it to a literal, but with spaces between. >>> >> (Variant: >>> >> >>>>>>> --with LF's). >>> >> >>>>>>> >>> >> >>>>>>> Raze (;) does indeed flatten the list... >>> >> >>>>>>> ;z >>> >> >>>>>>> alphabravocharlie >>> >> >>>>>>> >>> >> >>>>>>> There's got to be a really neat extended Raze which includes >>> >> >>>>>>> separators. But the fastest I've been able to come up with is: >>> >> >>>>>>> >>> >> >>>>>>> b2o=: }.@((<' ') ;@,. ]) >>> >> >>>>>>> b2o z >>> >> >>>>>>> alpha bravo charlie >>> >> >>>>>>> >>> >> >>>>>>> Any advances? >>> >> >>>>>>> >>> >> ---------------------------------------------------------------------- >>> >> >>>>>>> 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 >>> >> >> >>> ---------------------------------------------------------------------- >>> >> >> 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 >>> >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
