Now join itself would make a good standard
(as in other languages) addition to "strings" script,
to complement cut, split, etc.
'-' join ;:'a bc def'
a-bc-def
LF join ;:'a bc def' NB. a great relief at last
a
bc
def
Another interesting fact: adverb is 20% faster than verb:
(but verb interface is still more preferable)
ts'(;@(#^:_1!.(<a))~ 1 0$~_1 2 p.#) b'
0.0125231 1.57574e6
join=: ' '&$. : (4 : '(;@(#^:_1!.(<x))~ 1 0$~_1 2 p.#) y') NB. ignore $.
ts'a join b'
0.0166077 1.57638e6
joinA=: 1 : ';@(#^:_1!.(<m))~ 1 0$~_1 2 p.#'
ts'a joinA b'
0.0123689 1.57517e6
--- Oleg Kobchenko <[EMAIL PROTECTED]> wrote:
> Phenomenal. A good new line of thought.
>
> n=. 1 0$~<:+:#b NB. more general
> ts';n #^:_1!.(<a) b'
> 0.0122812 1.31219e6
>
> ts';((1 0$~_1 2 p.#) #^:_1!.(<a) ])b' NB. even with integrated n
> 0.0276326 2.13248e6
>
> ts'(;@(#^:_1!.(<a))~ 1 0$~_1 2 p.#)b' NB. but! tacitizing helps more
> 0.0124368 1.57594e6
>
> Interestingly, a similarly simpler expression
> has poorer time and space:
>
> ts'}:;1j1 #!.(<a) b' NB. }: is negligible
> 0.0780418 1.73027e7
>
> ts'}:1j1 ;@(#!.(<a)) b' NB. and tacitizing doesn't help
> 0.0779945 1.70406e7
>
>
____________________________________________________________________________________
Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for
today's economy) at Yahoo! Games.
http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm