Re: [Jprogramming] NYCJUG: Thinking in an Array Language

2022-07-19 Thread Hauke Rehr
Tom did, in the very post starting this thread: (1+i. 4 3) +/ . * 1+i. 3 4 38 44 50 56 83 98 113 128 128 152 176 200 173 206 239 272 Am 19.07.22 um 20:10 schrieb Devon McCormick: I'm puzzled why no one has used the basic matrix multiplication expression in J. matmul3 ([: +/ *)"1

Re: [Jprogramming] NYCJUG: Thinking in an Array Language

2022-07-19 Thread Devon McCormick
I'm puzzled why no one has used the basic matrix multiplication expression in J. matmul3 ([: +/ *)"1 _ mat1=. <.0.5+10*<:+:1000 1000?@$0 mat0=. <.0.5+10*<:+:1000 1000?@$0 (10) 6!:2 'mat0 matmul3 mat1' 0.737084 (10) 6!:2 'mat0 +/ . * mat1' 0.0499271 (mat0 matmul3 mat1) -: mat0 +/

Re: [Jprogramming] Problem with adverbs

2022-07-19 Thread Henry Rich
[:y has the important function of signaling domain error. Henry Rich On 7/19/2022 2:35 PM, 'Pascal Jasmin' via Programming wrote: I'll add that the fairly recent change of u@n being a constant verb for n is very positive. Of the approaches I suggested for defining the adverb, the first I

Re: [Jprogramming] NYCJUG: Thinking in an Array Language

2022-07-19 Thread Devon McCormick
I missed that. I think this is an elegant way that avoids explicit rank. On Tue, Jul 19, 2022 at 2:13 PM Hauke Rehr wrote: > Tom did, in the very post starting this thread: > > (1+i. 4 3) +/ . * 1+i. 3 4 > 38 44 50 56 > 83 98 113 128 > 128 152 176 200 > 173 206 239 272 > > Am

Re: [Jprogramming] Problem with adverbs

2022-07-19 Thread 'Pascal Jasmin' via Programming
it's not a big deal. a generic polymorphic replacement to @ is: >: {{if. isNoun 'v' do. u n else. u@v end.}}3 4 1 >: 2 : 'if. isNoun ''v'' do. u n else. u@v end.' + 3 5 but I think forming trains in form of ([: u n) as an escape when using (`:6) formation (more flexible than "real forks")

Re: [Jprogramming] Problem with adverbs

2022-07-19 Thread 'Pascal Jasmin' via Programming
I'll add that the fairly recent change of u@n being a constant verb for n is very positive. Of the approaches I suggested for defining the adverb, the first I prefer. expecting an adverb to always return a verb is more user friendly than deciding for them. (>:@1) 3 2 is good behaviour if

Re: [Jprogramming] NYCJUG: Thinking in an Array Language

2022-07-19 Thread Thomas McGuire
I had a chance to digest the K-way of lists of a list method Raul presented in J. After I understood it somewhat and its use of the leaf operator. I was curious as how fast these things ran, as implied by Raghu and Raul it was fairly slow compared to the J matrix implementation proposed by

Re: [Jprogramming] NYCJUG: Thinking in an Array Language

2022-07-19 Thread Elijah Stone
On Tue, 19 Jul 2022, Thomas McGuire wrote: Now the wierd thing is the timing for matmul3 is slow on par with emulating K matrices in J But if I use the fork directly it is as fast as Raul’s solution You are measuring two completely different things. 10 timex'bmat1 ([: +/ *)"1 _ bmat2'

Re: [Jprogramming] NYCJUG: Thinking in an Array Language

2022-07-19 Thread Thomas McGuire
My late night laziness and I got bitten by the 13 : definition doesn’t always work correctly with both x and y variables. Which I just assumed was working correctly. Now when I fix the definition of matmul3 so it works correctly (as Elijah pointed out) the variable representation does not

Re: [Jprogramming] Problem with adverbs

2022-07-19 Thread 'Pascal Jasmin' via Programming
some options, if you want your adverb to always produce a verb:  1 (>:@) >:@1 1 (>:@) 4 2  NB. increment  on constant of 1 (u/m parameter)   +: (>:@) 4 9  NB. increment after applying u (double) to y if you want "polymorphism" in your adverb to return noun result or verb depending on u