---R.E. Boss wrote:
> NB. if t is odd, delete last box and raze
> ;}:^:(2|#t1),t1,.t2
> a b c c d e e <span>e e e</span> f e f e f a a <span>a</span> f f
> <span>f</span>
>
>
> T=: 3 : 0
> t0=. ;<@i."0 #/.~ +/\1,2~:/\y
> t1=. (' '}:@,@,.~])&.> y <;.2~((2=1|.t0)*.t0=1.)+.(0=1|.!.0 t0)*.t0>1
> t2=.(#t1) $' <span>';'</span> '
> ;}:^:(2|#t1),t1,.t2
> )
Both your solution and mine need fixing to handle cases with odd numbers of
groups. Raul's is fine.
t3=. 'abccdeeeeefefefaaaffg'
bookend space group1 t3
a b c c d e e <span>e e e</span> f e f e f a a <span>a</span> f f g <span>
T t3
a b c c d e e <span>e e e</span> f e f e f a a <span>a</span>
teas <"0 t3
a b c c d e e <span>e e e</span> f e f e f a a <span>a</span> f f g
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm