Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread Ric Sherlock
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){'';

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread Devon McCormick
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

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread Ric Sherlock
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. >

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread Devon McCormick
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 ' '-.~,

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread Ric Sherlock
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

[Jprogramming] Bug in Calculus

2021-02-04 Thread 'Jon Hough' via Programming
I wrote a bug report and fix in the source chat a couple of weeks ago. There was no response, so I guess I wrote in the wrong chat. The calculus addon script has one glaring issue, and one small issue with an easy fix. The glaring issue is the inability to differentiate the constant zero functi

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread Ben Gorte
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

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread Raul Miller
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:

Re: [Jprogramming] Error in addons/math/misc/fermat.ijs

2021-02-04 Thread chris burke
Thanks, fixed now. The code dates from the time when x. was the left argument. On Thu, Feb 4, 2021 at 4:00 PM 'Michael Day' via Programming wrote: > > Having a look at the scripts in ~addons/math/misc, I've just noticed a > slip in > fermat.ijs - I doubt if it's used much, though, which is pr

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread Ric Sherlock
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

[Jprogramming] Error in addons/math/misc/fermat.ijs

2021-02-04 Thread 'Michael Day' via Programming
Having a look at the scripts in ~addons/math/misc,  I've just noticed a slip in fermat.ijs - I doubt if it's used much,  though,  which is probably why it hasn't been reported.  Its fellow script,  pollard.ijs,  has a greatly superior factoring algorithm or two. The optional left argument of t

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread Hauke Rehr
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

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread 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, -- 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

Re: [Jprogramming] 903-beta-d

2021-02-04 Thread 'Michael Day' via Programming
Sorry, Eric.  I don't know if it's a feature of the previously faulty Windows version,  but I tried deleting j.dll.old,  and was told it was in use by JQt, although Task Manager showed no sign of JQt or j.dll!  BUT I was able to change its name (j.dll.older ) , restarted J 903, and ran update s

Re: [Jprogramming] 903-beta-d

2021-02-04 Thread Eric Iverson
Sounds like another J session was in the way. Be sure all J's are closed and then start j903 and try again. On Thu, Feb 4, 2021 at 11:08 AM 'Michael Day' via Programming < programm...@jsoftware.com> wrote: > I always forget how to upgrade, so I usually use my own update verb, > pretty sophistica

Re: [Jprogramming] 903-beta-d

2021-02-04 Thread 'Michael Day' via Programming
I always forget how to upgrade,  so I usually use my own update verb, pretty sophisticated,  as you can see:    update 3 : 0    load'pacman'    'upgrade' jpkg 'jengine' ) This happened:    update'' upgrade failed - ferase j.dll.old - exit all J sessions and try again Any thoughts before I do w

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread 'Michael Day' via Programming
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

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread Hauke Rehr
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

Re: [Jprogramming] 903-beta-d

2021-02-04 Thread Eric Iverson
Setting up a new win10 development/test machine led to an error in building windows j903-beta-d. Some of the latest changes were not included. The build has been redone and uploaded. The crash on the second load of rubbish is fixed. Get the latest with: start J903 load'pacman' 'upgrade'jpk

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread Hauke Rehr
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

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread Raul Miller
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

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread 'Michael Day' via Programming
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

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread Ric Sherlock
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

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread Ric Sherlock
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' > > {{ ((

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread Ric Sherlock
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

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread 'Pascal Jasmin' via Programming
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

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread Hauke Rehr
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,

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread '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 Sherlo

Re: [Jprogramming] Progressive insertion into a string

2021-02-04 Thread Hauke Rehr
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