oopless Code VI: Temporary Variables<
>> https://www.jsoftware.com/help/jforc/loopless_code_vi_temporary_v.htm>
>> where I learned it.
>>
>>
>>
>>
>>
>> R.E. Boss
>>
>>
>>
>>
>>
>> -Original Message-
>> F
ss
>>
>>
>>
>>
>>
>> -----Original Message-
>> From: Programming On Behalf
>> Of Hauke Rehr
>> Sent: vrijdag 5 februari 2021 12:50
>> To: programm...@jsoftware.com
>> Subject: Re: [Jprogramming] Progressive insertion into a string
t;
>
>
> -Original Message-
> From: Programming On Behalf Of
> Hauke Rehr
> Sent: vrijdag 5 februari 2021 12:50
> To: programm...@jsoftware.com
> Subject: Re: [Jprogramming] Progressive insertion into a string
>
>
>
> It took me a little to understand
com
Subject: Re: [Jprogramming] Progressive insertion into a string
I’ll sure take a look. I do think this belongs into any idiomatic J
programmer’s toolset.
Is there actually a kind of compilation of such a toolset yet?
I found some spread on the phrases & dictionary which both serve a broade
Of
> Hauke Rehr
> Sent: vrijdag 5 februari 2021 12:50
> To: programm...@jsoftware.com
> Subject: Re: [Jprogramming] Progressive insertion into a string
>
>
>
> It took me a little to understand why this works (I first didn’t get /&.|.
> actually works front-to-b
where I learned it.
R.E. Boss
-Original Message-
From: Programming On Behalf Of Hauke
Rehr
Sent: vrijdag 5 februari 2021 12:50
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Progressive insertion into a string
It took me a little to understand why this works
sage-
From: Programming On Behalf Of Hauke
Rehr
Sent: vrijdag 5 februari 2021 12:50
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Progressive insertion into a string
It took me a little to understand why this works (I first didn’t get /&.|.
actually works front-to-back) I like thi
+--+
>
> Then
>
>soln (-: 'X' v0a L:0 ])&}:data
> 1
>
>
> R.E. Boss
>
>
> -Original Message-
> From: Programming On Behalf Of
> R.E. Boss
> Sent: vrijdag 5 februari 2021 10:33
> To: pr
---+--+
v1 S:0 v0 L:0 }:data NB. All (but last) solutions are correct
1 1 1 1
R.E. Boss
-Original Message-
From: Programming On Behalf Of Ric
Sherlock
Sent: vrijdag 5 februari 2021 02:35
To: Programming JForum
Subject: Re: [Jprogramming] Progress
S:0 v0 L:0 }:data NB. All (but last) solutions are correct
1 1 1 1
R.E. Boss
-Original Message-
From: Programming On Behalf Of Ric
Sherlock
Sent: vrijdag 5 februari 2021 02:35
To: Programming JForum
Subject: Re: [Jprogramming] Progressive insertion into a string
Yes as Hau
;THEEQUICKBROWFOOX'
1
R.E. Boss
-Original Message-
From: Programming On Behalf Of Ric
Sherlock
Sent: donderdag 4 februari 2021 13:41
To: Programming JForum
Subject: Re: [Jprogramming] Progressive insertion into a string
This is very nice Pascal, but not quite right. The correct o
showDigraphs 'AAXAbbCCCXC'
"AA,XA,bb,CC,CX,C"
No as you can see there are 3 digraphs in that string that have repeated
letters.
dedouble 'AAAbb'
AXAXAbbCCXCXC
On Fri, Feb 5, 2021 at 6:02 PM Devon McCormick wrote:
> So like this?
>dbld=. <"1]_2 ]\ str
>;dbld,&.>(>=/&>dbld){'';
So like this?
dbld=. <"1]_2 ]\ str
;dbld,&.>(>=/&>dbld){'';'X'
AAXAbbCCCXC
On Thu, Feb 4, 2021 at 11:56 PM Ric Sherlock wrote:
> Only repeats that occur within a digraph need to be split, so:
>
>showDigraphs dedouble 'AAABB'
> "AX,AX,AB,BC,CX,CX,C"
>
> On Fri, Feb 5, 2021 at 5:53
Only repeats that occur within a digraph need to be split, so:
showDigraphs dedouble 'AAABB'
"AX,AX,AB,BC,CX,CX,C"
On Fri, Feb 5, 2021 at 5:53 PM Devon McCormick wrote:
> How do you propose to handle triples and so on? If you are using _2]\
> instead of 2]\, you miss half the repeats.
>
How do you propose to handle triples and so on? If you are using _2]\
instead of 2]\, you miss half the repeats.
str=. 'AAAbb'
((2 ]\ ]);_2 ]\ ]) str NB. Two ways of windowing.
+--+--+
|AA|AA|
|AA|Ab|
|Ab|bC|
|bb|CC|
|bC|C |
|CC| |
|CC| |
|CC| |
+--+--+
dbld=. 2 ]\ str
' '-.~,
Using ideas from the solutions so far, this is the version I currently
prefer:
getidx=: 1 >:@+:@i.~ =/"1@(_2 ]\ ])
splitDigraph=: ({. , 'X' , }.)~ getidx
dedouble=: dtb@:(>:@# {. splitDigraph)^:_
(soln1;soln2;soln3;soln4;soln5) -: dedouble&.>
data1;data2;data3;data4;data5
1
On Fri, Feb 5, 20
Ah yes, better!
Works on the five test cases :-)
On Thu, 4 Feb 2021 at 23:13, Ric Sherlock wrote:
> Thanks, yes that works!
> Here's a slightly simpler take on the same approach:
> {{ ((+ idx&<)#y) {. y ({. ,'X', }.)~ idx =. >:+: 1 i.~ (=/"1) _2 ]\y }}^:_
>
> On Thu, Feb 4, 2021 at 8:48 PM Ben
Well...
That's actually a pretty big flaw in my implementation -- once there's
a letter pair which is not in a digraph, my rewrite completely fails.
It's certainly fixable, but with significant added complexity.
For example, this almost works:
lookup=: {&((8#2),8$0 3)
digrap=: # {. {. , 2|[:]F:
Yes as Hauke has previously identified, we need some more test cases to
fully test whether the spec is correctly implemented or not.
I'm thinking that the example outputs you've shown in your email aren't
correct, but I agree that your approach and Raul's generate different
solutions for that input
The reason is ignorance on my side, so that’s a bad one :-)
Am 04.02.21 um 17:29 schrieb Raul Miller:
> The problem with 0,~ is that it throws an error when dedouble is
> passed an empty argument. Is there a good reason for throwing that
> error?
>
> Thanks,
>
--
--
mail wr
The problem with 0,~ is that it throws an error when dedouble is
passed an empty argument. Is there a good reason for throwing that
error?
Thanks,
--
Raul
On Thu, Feb 4, 2021 at 10:31 AM Hauke Rehr wrote:
>
> Now that looks way better than what I did.
> After digra, it works differently.
> I’d
Just before I venture into updating to the correct beta d...
Raul's is elegant, single-pass and pretty spare. Here's a verbose,
inelegant,
multi-pass one, but it seems to work, except perhaps for the last
example,
below.
I stuck with _2 which means that with odd length strings an error is
Now that looks way better than what I did.
After digra, it works differently.
I’d still say 0,~ instead of #{. because
there is no dependence on its #, really.
Every now and then I see uses of j. I wouldn’t
have thought of. Is the list at the bottom of
nuvoc’s jdot entry complete?
I should start m
My solution should have met the specification.
But you’re right, it’s far from simple
(though its idea is – so I’m just bad at J).
Am 04.02.21 um 11:49 schrieb Ric Sherlock:
> Sorry I should have been a bit more explicit with the specification.
>
> The reason that the double O in the 2nd example
Ah, I see it now -- I should have looked closer at your digraphs.
Here's a fixed version:
digra=: * 2 | i.@# + +/\
dedouble=: #!.'X'~ 1 j. [: digra #{.}.=}:
(I could not think of a good name for the "compress out splits of
non-digraphs" mechanism.)
The moral of the story here is that numeric ca
I know you're interested in developing encode and decode for Playfair,
but members _might_ like to know that the London Times "Listener"
crosswords*,
which appear every Saturday, occasionally employ Playfair codes.
FYI, I've found these pertinent puzzles in my records:
4236 4303 4406 44
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
Thanks, yes that works!
Here's a slightly simpler take on the same approach:
{{ ((+ idx&<)#y) {. y ({. ,'X', }.)~ idx =. >:+: 1 i.~ (=/"1) _2 ]\y }}^:_
On Thu, Feb 4, 2021 at 8:48 PM Ben Gorte wrote:
> Think I've got it:
>
> data1 =: 'THEEQUICKBROWFFOX'
>
> data2 =: 'THEEQUICKBROWFOOX'
>
> {{ ((
Sorry I should have been a bit more explicit with the specification.
The reason that the double O in the 2nd example does not get an X inserted
is that once the X is inserted for the first double, the Os are split
between 2 digraphs and no longer require to be separated. In other words,
after the
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
wrote:
doesn’t all that boxing/unboxing and cutting/gluing hurt?
maybe I have to stop thinking ab
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,
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 Sherlo
Ouch, I made the same mistake, but even worse.
This time I actually care about a possible
doublette at the very start.
And the code looks a little bit less messy this way.
But I’m done playing with this.
I think Ben’s version is okay.
Getting it done without looping may be interesting,
but I don’t
I wanted to do it without looping.
But my solution was incorrect.
The error just didn’t show with
the examples given.
Maybe I’ll find a better way.
Or at least refactor it a bit.
For now, this is at least correct:
i =: 0 -.~ (* i.@#)
s =: 2 : 0
a =. i m=y
n a} y
)
NB. ugly, repetitive junk solu
Think I've got it:
data1 =: 'THEEQUICKBROWFFOX'
data2 =: 'THEEQUICKBROWFOOX'
{{ ((+where&<)#y) {. ({.&y ,'X', }.&y) where =. >: +: 1 i.~ _2 =/\
y,'XX',(2|#y){.'X' }}^:_ data1
THEXEQUICKBROWFXFOX
{{ ((+where&<)#y) {. ({.&y ,'X', }.&y) where =. >: +: 1 i.~ _2 =/\
y,'XX',(2|#y){.'X' }}^:_ data2
I show this only as a different way to deal with it.
There’s much space for improvement.
It works correctly with the two examples you gave.
data1 =: 'THEEQUICKBROWFFOX'
data2 =: 'THEEQUICKBROWFOOX'
res1 =: 'THEXEQUICKBROWFXFOX'
res2 =: 'THEXEQUICKBROWFOOX'
s =: 2 : 0
a =. 0 -.~ (* i.@#) m=y
n a
I would be tempted to go with
dedouble=: #!.'X'~ 1 j. #{.}.=}:
But I do not understand why the double O in your second example does
not get an X inserted. So maybe I am missing something.
I hope this helps,
--
Raul
On Wed, Feb 3, 2021 at 11:02 PM Ric Sherlock wrote:
>
> I need to separate an
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 separ
38 matches
Mail list logo