None of these versions seem to provide much (any?) benefit over and
above the joinstring verb from strings.

   timespacex 'b2o x'
0.145468 4.1748e7
   timespacex 'b2q x'
0.145305 4.1748e7
   timespacex 'SP joinstring x'
0.143562 4.17485e7

When we inspect joinstring the reason becomes clear ... they are doing
essentially the same thing except that joinstring takes a left
argument which defaults to ''.
joinstring=: ''&$: : (#@[ }. <@[ ;@,. ])
bto=:                 }.@((<' ') ;@,. ])

Note that the inverse of joinstring is:
splitstring=: #@[ }.each [ (E. <;.1 ]) ,


On Fri, Sep 7, 2012 at 5:00 PM, 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

Reply via email to