Henry -

I'd support Roger's intuition on this one: inserting separators between
items and
unboxing them seems like two distinct operations.  It doesn't fit neatly as
the obverse
of boxing because it requires added information.

I have long had a simple utility to do this in a slightly more general
fashion than you
require:

punclist=: 3 : 0
NB.* punclist: punctuate boxed list y with character(s) x between each item.
  ', ' punclist y
:
  (-#x)}.;(":&.>y),&.><x
)

  '-' punclist 'a';'bc';'def'
a-bc-def
  punclist 'a';'bc';'def'
a, bc, def

As you might surmise from the default case, I most commonly use this to
format
a vector of words into a comma-separated list.

Devon

On 6/14/07, Henry Rich <[EMAIL PROTECTED]> wrote:

I often have boxed data like

'a';'bc';'def'

that I want to run together with delimiters, for example

a-bc-def

I admit this is not such a challenge; my best solution is

}:@;@:(,&'-'&.>) 'a';'bc';'def'


But I don't like the way it looks; especially I don't like
that }: is really the obverse of (,&'-') but that fact does not
appear (and I don't want to add yet more code by replacing }:
with ,&'-'^:_1 ).

We have a function that runs boxes together: ;:^:_1 .  Why
not let it take a Fit that gives the delimiter
(' ' by default)?  Then I would write

;:^:_1!.'-' 'a';'bc';'def'

Much more elegant, I say.

Henry Rich

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm




--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to