I use a join definition from a thread in the middle of last year. NB.*join v Unbox and delimit a list of boxed items y with x NB. form: Delimiter join BoxedList NB. eg: '","' join 'item1';'item2' NB. eg: LF join 'item1';'item2' NB. eg: 99 join <"0 i.8 NB. from forum post NB. http://www.jsoftware.com/pipermail/programming/2007-June/007077.html join=: ' '&$. : (4 : '(;@(#^:_1!.(<x))~ 1 0$~_1 2 p.#) y') NB. ignore $.
> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Oleg Kobchenko > Sent: Saturday, 26 July 2008 16:11 > To: Programming forum > Subject: [Jprogramming] Split and Join ... did it again > > Wasn't able to find the popular elesewhere string > funcitons Split and Join, and had to write them > again from scratch. Here's this time variants: > > NB. split y by substring x; see join > split=: [EMAIL PROTECTED] }.each [ (E. <;.1 ]) , > > NB. join boxed list y with x; see split > join=: [: ; [EMAIL PROTECTED] , [: , [EMAIL PROTECTED] ,. [EMAIL PROTECTED] > > > ','join' 'split '1 2 3 one two three' > 1,2,3,one,two,three > > '<'join' of 'split 'a of b of c' > a<b<c > > '['[EMAIL PROTECTED]']'(join ,&a:)'[a';'[b';'[c' > +--+--+--+ > |a]|b]|c]| > +--+--+--+ > > Interestingly, they are strikingly similar to existing > in the Wiki http://www.jsoftware.com/jwiki/Phrases/Strings > So it pays to look first. > > Also it calls for some kind of process to assimilate > more frequent phrases into base libraries of addons. > This is a case when by themselves these phrases are small > and warrant a separate addon or linrary, but could be > added to existing ones. > > > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
