Re: [Jprogramming] Removing annihilating pairs

2019-12-07 Thread Raul Miller
In my tests, on longer sequences, Henry Rich's approach seemed about the same speed as mine. Thanks, -- Raul On Sat, Dec 7, 2019 at 6:33 AM R.E. Boss wrote: > Forcrand's solution is more or less the version I came up with, > unfortunately, it's far from linear (what is not compensated by its

Re: [Jprogramming] Selecting trains with m@.v

2019-12-07 Thread 'Jim Russell' via Programming
As always Brian, I am impressed; and probably will be even more so after the time it will take me to understand the documents you and Jimmy referenced. Long ago I concluded that x (exp1;exp2;...;expn) y was just a way for smart j'ers to let beginners like me to compare the results of related e

Re: [Jprogramming] Selecting trains with m@.v

2019-12-07 Thread Brian Schott
The expression X exp1;exp2;exp3 Y needs ()'s to be properly constructed as a 5 element "train": X (exp1;exp2;exp3) Y. As near as I can tell it is referenced in the following link. https://www.jsoftware.com/help/dictionary/dicte.htm On that page the reference is to the following page: https://ww

Re: [Jprogramming] Selecting trains with m@.v

2019-12-07 Thread ethiejiesa via Programming
> is the following what you want ? > >1 2 3 (+ ; * ; -) 6 7 8 Not quite. The example in my original email was probably overly minimal to be completely unhelpful. This is closer to what I am trying to do: (+1:)`*`%`(+2:)@.(0 , (1 + 2&|) , 3:)"0 [ 5 6 NB. fictional usage 0.857143

Re: [Jprogramming] Selecting trains with m@.v

2019-12-07 Thread 'Jim Russell' via Programming
Thank you. I may reply more in a year ot two when I have fully grokked Roger’s note in your reply! Wanting to be snippy in a complaint I was making to my local bank, I wanted to compare how many prime numbers my iPhone (using J) could calculate in the 15 seconds their cash machine took to read

Re: [Jprogramming] Selecting trains with m@.v

2019-12-07 Thread Jimmy Gauvin
Hi, The first vocabulary is full of information. So much so that it is easy to overlook lots of "tasty tidbits". The answer your question " where is that first explained to the J Beginner ? " , it is not so much explained but rather demonstrated. I had to change my reading style from "passive assi

Re: [Jprogramming] Selecting trains with m@.v

2019-12-07 Thread 'Jim Russell' via Programming
As shown throughout the Vocabulary. But where is that first explained to the J Beginner? > On Dec 7, 2019, at 1:08 PM, Jimmy Gauvin wrote: > > Hi, > > note also that the shape of the results can vary considerably : > > 1 2 3 (+ ; * ; - ; +/ ; ,&4 5) 6 7 8 > ┌──┬───┬┬───┬─

Re: [Jprogramming] Selecting trains with m@.v

2019-12-07 Thread Jimmy Gauvin
Hi, note also that the shape of the results can vary considerably : 1 2 3 (+ ; * ; - ; +/ ; ,&4 5) 6 7 8 ┌──┬───┬┬───┬─┐ │7 9 11│6 14 24│_5 _5 _5│7 8 9│6 7 8 4 5 0 0 0 0│ │ │ ││8 9 10│6 7 8 4 5 4 5 0 0│ │ │ ││9 10 11│6 7

Re: [Jprogramming] Selecting trains with m@.v

2019-12-07 Thread 'Jim Russell' via Programming
Does this shed any light on the mystery?? J Http Server |ill-formed name: null_ *** response not sent for ~addons/docs/help/dictionary/null *** html409 Conflict I had not seen any of the Safari/Reader errors included in my original message until just now, when I replied to it > On Dec 7, 20

Re: [Jprogramming] Selecting trains with m@.v

2019-12-07 Thread 'Jim Russell' via Programming
Another rabbit hole… This expression format is used throught the original Iverson/Hui Vocabulary, and I had always been bothered that I had to figure out what was going on before I could get much value from the Vocabulary examples. To investigate what I had missed long ago, I was in JHS, and

Re: [Jprogramming] Selecting trains with m@.v

2019-12-07 Thread 'Jim Russell' via Programming
Lovely! Not at all obvious (to me)until you do it with simple verbs. > On Dec 7, 2019, at 9:30 AM, Jimmy Gauvin wrote: > > Hi, > > is the following what you want ? > > 1 2 3 (+ ; * ; -) 6 7 8 > ┌──┬───┬┐ > │7 9 11│6 14 24│_5 _5 _5│ > └──┴───┴┘ > > > >> On

Re: [Jprogramming] Removing annihilating pairs

2019-12-07 Thread R.E. Boss
What amazes me most is the influence (of your Moral: Always append to the end of arrays) on the performance. ts' d 1 _1 2 _2 {~ 1 ?.@# 4' 0.0032329 528576 ts' d 1 _1 2 _2 {~ 10 ?.@# 4' 0.0313838 4198080 ts' s 1 _1 2 _2 {~ 1 ?.@# 4' 0.0178007 855744 ts' s 1 _1 2 _2 {~

Re: [Jprogramming] Selecting trains with m@.v

2019-12-07 Thread Henry Rich
You are right, it doesn't allow trains when v is a verb. Henry Rich On 12/6/2019 9:54 PM, ethiejiesa via Programming wrote: Am I just doing something silly? Or does @. really not support building trains when the right operand is a verb? Here is an overly minimal example of what I want:

Re: [Jprogramming] Selecting trains with m@.v

2019-12-07 Thread Jimmy Gauvin
Hi, is the following what you want ? 1 2 3 (+ ; * ; -) 6 7 8 ┌──┬───┬┐ │7 9 11│6 14 24│_5 _5 _5│ └──┴───┴┘ On Fri, Dec 6, 2019 at 9:54 PM ethiejiesa via Programming < programm...@jsoftware.com> wrote: > Am I just doing something silly? Or does @. really not

Re: [Jprogramming] Removing annihilating pairs

2019-12-07 Thread Louis de Forcrand
First some bad news: s=: ,`(}.@])@.(= -@{:)/ s 1 _1 0 1 _1 0 s=: ,`(}.@])@.(= -@{.)/ s 1 _1 0 0 s 0 1 _1 So our solutions don't work if the accumulator array goes empty before the end. Fortunately this can be fixed (see below). Now some good news: s=: ,`(}.@])@.(0:`(= -@{.)@.

Re: [Jprogramming] Removing annihilating pairs

2019-12-07 Thread R.E. Boss
Forcrand's solution is more or less the version I came up with, unfortunately, it's far from linear (what is not compensated by its elegance). foo=: ,`(}.@])@.(0=(+{.))/ ts'foo 1 _1 2 _2{~1?.@#4' 0.0166915 854720 ts'foo 1 _1 2 _2{~10?.@#4' 1.9109807 6818496 Miller's solutio