On Thu, Jul 10, 2008 at 6:47 PM, Sherlock, Ric
<[EMAIL PROTECTED]> wrote:
> 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>
>
> In English:
> Group together all duplicate items that occur anytime beyond twice by
> wrapping them with a tag, naturally "bookending" them.
>
> Spoiler Alert.
> ==============
> My solution below.
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Finding the mask of the atoms that need enclosing was Ok. But I find my
> solution for enclosing them long winded and overly complex. Is there a better
> way?
t=: <"0 'abccdeeeeefefefaaafff'
span=: (]`2:`[} '<span>' <@, 2&{::)@(]`_1:`[} '</span>' <@,~ _1&{::)^:(2<#)
teas=: [:; ,&.>&' '@;@(<@span/.~ 1 +/\@, 2 ~:/\ ])
teas t
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>
--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm