This is very nice Pascal, but not quite right. The correct output for
'THEEQUICKBROWFOOX' should be 'THEXEQUICKBROWFOOX' (See reply to Raul for
more detail)
If we could get it to only apply to the first instance of a doubled
digraph, then iterating until there is no more change (^:_) would produce
the correct result.
From playing with it, I'm not sure that's possible because the scope of @.
is restricted to the individual digraphs?

On Thu, Feb 4, 2021 at 10:14 PM 'Pascal Jasmin' via Programming <
programm...@jsoftware.com> wrote:

> if spaces are not allowed, then without boxing:
>
> (' ' -.~ ,)@:(_2&(,`([,'X',])@.=/\)) 'THEEQUICKBROWFOOX'
>
> THEXEQUICKBROWFOXOX
>
>
>
>
>
>
> On Thursday, February 4, 2021, 03:57:44 a.m. EST, Hauke Rehr <
> hauke.r...@uni-jena.de> wrote:
>
>
>
>
>
> doesn’t all that boxing/unboxing and cutting/gluing hurt?
> maybe I have to stop thinking about improvements that
> actually aren’t improvements.
>
> Nice readable approach!
>
> Am 04.02.21 um 09:51 schrieb 'Pascal Jasmin' via Programming:
> > assuming you want all dedoubled on a pass and not just first match,
> >
> >
> >
> > ;@:(_2&(,`([,'X',])@.=/each@<\))^:_ 'THEEQUICKBROWFFOOOX'
> >
> > THEXEQUICKBROWFXFOXOXOX
> >
> >
> > ;@:(_2&(,`([,'X',])@.=/each@<\)) 'THEEQUICKBROWFFOOOX'
> >
> > THEXEQUICKBROWFFOOXOX
> >
> >
> >
> >
> > On Wednesday, February 3, 2021, 11:02:49 p.m. EST, Ric Sherlock <
> tikk...@gmail.com> wrote:
> >
> >
> >
> >
> >
> > I need to separate any digraphs in a string, that consist of 2 letters
> the
> > same, by inserting an 'X' between them.
> >   _2 ]\ 'THEEQUICKBROWFFOX'
> > TH
> > EE
> > QU
> > IC
> > KB
> > RO
> > WF
> > FO
> > X
> >
> > 'EE' is a digraph that needs an 'X' inserted. Doing so will result in:
> >
> > TH
> > EX
> > EQ
> > UI
> > CK
> > BR
> > OW
> > FF
> > OX
> >
> > So now we also need to separate the 'FF' digraph.
> >
> > I want to define a verb "dedouble" that will process a string so:
> >   dedouble 'THEEQUICKBROWFFOX'
> > THEXEQUICKBROWFXFOX
> > But:
> >   dedouble 'THEEQUICKBROWFOOX'
> > THEXEQUICKBROWFOOX
> >
> > I have implemented a solution at
> > https://rosettacode.org/wiki/Playfair_cipher#J but am interested in
> > alternative implementations.
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
>
> --
> ----------------------
> mail written using NEO
> neo-layout.org
>
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to