As you point out, these are not equivalent. # TEST=: ' this is a test ' 26 # deb TEST 14 # fdeb TEST 15
Note also: # ]&.;: TEST 14 That said: # ]&.;: ' Don''t do this... ' |open quote Also, the timing difference between 3.446e_6 and 3.293e_6 is inconsequential. -- Raul On Wed, Jan 4, 2012 at 2:14 AM, Alan Stebbens <a...@stebbens.org> wrote: > "delete extra blanks" from strings.ijs has this definition: > > deb =: #~ (+. (1: |. (> </\)))@(' '&~:) > > NB. Here is a slightly faster deb: > > fdeb =: [ #~ [: -. [: (] *. 1&|.) ' ' = [ > > NB. s is the test string; w is its boxed words > > w=.;:s=.'now is the time for all good men to come to the aid of their > country' > w > +---+--+---+----+---+---+----+---+--+----+--+---+---+--+-----+-------+ > |now|is|the|time|for|all|good|men|to|come|to|the|aid|of|their|country| > +---+--+---+----+---+---+----+---+--+----+--+---+---+--+-----+-------+ > > NB. show > 1000 tx 'deb ,>w' > 3.446e_6 3072 > > 1000 tx 'fdeb ,>w' > 3.293e_6 3072 > > NB. same value for both the old and new fun > (deb -: fdeb),>w > 1 > > NB. the results match the original string > s -: fdeb ,>w > 1 > > However, it's not exactly the same as deb: it doesn't remove a single leading > blank, as does deb (which, IMHO, is not necessarily an "extra" blank anyway). > > Alan > > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm