Re: [Jprogramming] complex amend

2019-02-21 Thread Brian Schott
Arie, I now see that my comment regarding a Hook was irrelevant (if not just wrong) because the lha of the amend gerund supplies the m in m}. So to get different strides is just a matter of supplying a different set of array indices for the lha From. So, all that's needed for different strides is

Re: [Jprogramming] complex amend

2019-02-20 Thread Aai
Yes it's Arie = Aai = @@i (sounds like I). :-) On 20-02-19 16:57, Brian Schott wrote: Aii, (Is it Ari?) Yes, that is a nice extension that absolutely anticipates my expanded needs. I played with increasing the dimensions of i and w a little and it works beautifully. (Please follow below this

Re: [Jprogramming] complex amend

2019-02-20 Thread Brian Schott
Aii, (Is it Ari?) Yes, that is a nice extension that absolutely anticipates my expanded needs. I played with increasing the dimensions of i and w a little and it works beautifully. (Please follow below this little demonstration of expanded dimensions for more discussion) ;/($ $"1 ((0 0;0 _1;_

Re: [Jprogramming] complex amend

2019-02-20 Thread Aai
Perhaps this is also useful: ka=:'abcdefghijklmnopqrstuvwxyz' Ga=:'MNOPQRSTUVWXYZABCDEFGHIJKL' NB. stretch -- amend -- unstretch (reshape) ($ $"1 ((0 0;0 _1;_1 0 ;_1 _1){($ w),;._3 i. $ i)(,w)"_`[`] }"1 ,) i=.3 3 $ Ga [ w=. 2 2 $ ka Handles variable 2D shaped arrays AFAICS Also of course:    

Re: [Jprogramming] complex amend

2019-02-19 Thread Raul Miller
You are right, this could have been done using the gerund form of } w=: 2 2$'abcd' i=: 3 3$'MNOPQR' w"_`]`(i"_)}~@<"1(#:i.4){;/+/~0 1 Basically, w"_`]`(i"_)}~ behaves like (w 2 :'m y}n'i) They are not equivalent in all contexts (they have different display forms, for example), bu

Re: [Jprogramming] complex amend

2019-02-19 Thread Brian Schott
Raul,Yes. That is TOO clever (see why, below).Your approach provides a way to avoid using gerund form of } .Making the <"1 part of a verb (and especially the "1 part of <"1) instead of including it in the construction of the verb's righthand argument noun, brings your conjunction's y into the amend

Re: [Jprogramming] complex amend

2019-02-19 Thread Raul Miller
Mine wasn't a solution, more of a hint. I got the rank wrong. That said, the issue you mentioned would break code in just about any language: my quotes had gotten changed to something else. Anyways, here's a solution: (w 2 :'m y}n'i)@<"1(#:i.4){;/+/~0 1 abO cdR MNO Mab Pcd MNO MNO abR cdO

Re: [Jprogramming] complex amend

2019-02-18 Thread Brian Schott
Oops. I should have pointed out that Ric's result does have one less layer of boxing. On Tue, Feb 19, 2019 at 12:31 AM Brian Schott wrote: > Bob and Ric, > > Focusing separately on the 3 parts of the gerund form by placing ; between > the parts, really helps me see what you have done. (And btw,

Re: [Jprogramming] complex amend

2019-02-18 Thread Brian Schott
Bob and Ric, Focusing separately on the 3 parts of the gerund form by placing ; between the parts, really helps me see what you have done. (And btw, i should have contained 'STU' also. Thanks, again. Bob's version and Ric's version both produce virtually identical results; I prefixed Bob's version

Re: [Jprogramming] complex amend

2019-02-18 Thread 'robert therriault' via Programming
Nice Ric, I like the way that you packaged the selector inside the amend clause, as that gets around a lot of the boxing that I needed to coordinate the arguments. The only improvement I can see is that the infinite rank on amend is not needed as the rank 2 covers the w ; i argument. At least t

Re: [Jprogramming] complex amend

2019-02-18 Thread Ric Sherlock
Here is a version of the same idea but with less boxing. Interestingly it looks as though J9 will support the specifying indices using unboxed arrays which would simplify this further! load 'stats' ((0 1,:1 2) {~ permrep 2) (0&{::@]) `(<@:(<"1)@[)`(1&{::@]) }"2 _ w;i abO cdR MNO Mab Pcd M

Re: [Jprogramming] complex amend

2019-02-18 Thread 'robert therriault' via Programming
Hi Brian, My comments about boxing had more to do with all the boxing that needed to be done and then undone to get the right result. A couple of examples. (<"0 ind) to me just looks messy especially when it is already boxed, but the each/every adverb requires that. (< cmb) to just unpack i

Re: [Jprogramming] complex amend

2019-02-18 Thread Brian Schott
Bob, Yes. That's what I wanted. I'm not completely sure about your comment about the necessity of boxing and unboxing, though. I changed your each to every and got an unboxed result just like the result you gave, but I think your comment is deeper and I want to think more about it. I especially w

Re: [Jprogramming] complex amend

2019-02-18 Thread 'robert therriault' via Programming
I'll study Raul's solution a bit more, but in the meantime I think that this is what you may be looking for: [combis =: #:i. 4 NB. same definitions as before 0 0 0 1 1 0 1 1 [w=: 2 2$'abcd' ab cd [i=: 3 3$'MNOPQR' MNO PQR MNO [ind=: combis<"1@:{2<\i. 3 NB. capture the indices that

Re: [Jprogramming] complex amend

2019-02-18 Thread Raul Miller
You have a bunch of different values for r, and the final value has everything already “in place”. So it’s not completely clear what problem you are trying to solve. That said, my best guess would be that you are trying to achieve “use rank conjunction on the adverb argument to amend.” If so, th

[Jprogramming] complex amend

2019-02-18 Thread Brian Schott
The snippet below produces a value for r which I would like to produce more elegantly: without the for. loop suggested by the repeated building of r-values. Perhaps a gerund-powered amend could work, but I am not optimistic enough to travel there without some encouragement. The result in r is atte