Re: [Jprogramming] Rank difficulties

2023-09-08 Thread Elijah Stone
J transpose is very nice. Apl transpose is bizarre and confusing. On Sat, 9 Sep 2023, Devon McCormick wrote: I love the way J and APL handle transposing multi-dimensional arrays because it's so easy to understand: the left argument of transpose is the vector of indexes of the shape in the orde

Re: [Jprogramming] Rank difficulties

2023-09-08 Thread Devon McCormick
I love the way J and APL handle transposing multi-dimensional arrays because it's so easy to understand: the left argument of transpose is the vector of indexes of the shape in the order you want it to be, as I've attempted to illustrate here: https://code.jsoftware.com/wiki/User:Devon_McCormick/Vi

Re: [Jprogramming] Rank difficulties

2023-09-08 Thread Henry Rich
I agree with Ben here.  Transposing arrays of rank > 2 has never seemed intuitive to me.  Taking a single slice is just one dimension smaller than a transpose. Say I want a slice of a 3-d array: all the atoms that have the same x index.  I should just... wait a minute, the remaining axes are y

Re: [Jprogramming] Rank difficulties

2023-09-07 Thread Ben Gorte
Hi Piet, > Slicing is a pretty intuitive concept so why should it be so intricate and “hard"? > Maybe this is one of the reasons why J is not as popular as it ought to be. In the defence of J we might consider that the intuition of slicing is a bit ambiguous, which is the dangerous sort. The men

Re: [Jprogramming] Rank difficulties

2023-09-07 Thread 'Skip Cave' via Programming
Re the question: "why is J not as popular as it ought to be" I provide J solutions to various problems on Quora , mainly to improve my J programming skills. I have solved thousands of Quora problems over the last 8 years. Many of my solutions have tens of thousands of views,

Re: [Jprogramming] Rank difficulties

2023-09-07 Thread Piet de Jong
Thanks for all the great suggestions which has helped me a lot. To my mind it does raise a couple of issues or questions. I’ll stick my head out with them, knowing there might be much blowback. But bear with me. Slicing is a pretty intuitive concept so why should it be so intricate and “hard"?

Re: [Jprogramming] Rank difficulties

2023-09-07 Thread Jose Mario Quintana
Oops, I forgot o=. @: On Thu, Sep 7, 2023 at 1:27 PM Jose Mario Quintana < jose.mario.quint...@gmail.com> wrote: > > The order of the last two appear "unnatural". (To my way of thinking at > least) > > This seems to beg the question what is the natural order when slicing. > > The answer might d

Re: [Jprogramming] Rank difficulties

2023-09-07 Thread Jose Mario Quintana
> The order of the last two appear "unnatural". (To my way of thinking at least) > This seems to beg the question what is the natural order when slicing. The answer might depend on the intended usage of the verb that you have in mind. If, for example, you want to preserve the order of the remain

Re: [Jprogramming] Rank difficulties

2023-09-07 Thread Raul Miller
I believe Henry meant to say: ~.@(, i.@#@$) |: ] For example: $1 2 (~.@(, i.@#@$) |: ]) i. 2 3 5 7 11 3 5 2 7 11 Though, I imagine the typical case identifies only a single dimension in the left argument and a lower dimensional array in the right argument. For example: $ 1 (~.@(, i.@

Re: [Jprogramming] Rank difficulties

2023-09-07 Thread Jan-Pieter Jacobs
I think it would need specifying rank 0 and using /. m=: i. 5 4 3 0 2 {"0 2/ m NB. slices 0 2 at rank 2 0 1 2 12 13 14 24 25 26 36 37 38 48 49 50 6 7 8 18 19 20 30 31 32 42 43 44 54 55 56 slice =: {{ {"(0,m)/ }} NB. the same $0 2(3 slice) m 2 5 3 This way, the number of slices i

Re: [Jprogramming] Rank difficulties

2023-09-06 Thread 'Rob Hodgkinson' via Programming
I should have read Henry’s more carefully (sorry Henry), very similar approach, bust the display of the ‘slices’ differs. 1 HR a 0 12 4 16 8 20 1 13 5 17 9 21 2 14 6 18 10 22 3 15 7 19 11 23 1 T a 0 1 2 3 12 13 14 15 4 5 6 7 16 17 18 19 8 9 10 11 20 21 22 23 > On

Re: [Jprogramming] Rank difficulties

2023-09-06 Thread 'Rob Hodgkinson' via Programming
Very nice Ben, your TT is “hard coded to rank 3”, so fails on other than rank 3. I “tinkered” by replacing 0 1 2 with i. $ $, and converted to tacit using 13 : which worked, but less readable... ]a=:i.2 3 4 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ]b=:i.2 2 0

Re: [Jprogramming] Rank difficulties

2023-09-06 Thread Ben Gorte
Still not quite sure what you mean, but how about: ]n =: i.2 3 4 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 1{0 T n NB. -: 1{n 12 13 14 15 16 17 18 19 20 21 22 23 1{1 T n 4 5 6 7 16 17 18 19 1{2 T n 1 5 9 13 17 21 If that's the one, then T would be: T =: {{

Re: [Jprogramming] Rank difficulties

2023-09-06 Thread Piet de Jong
This works! Except the ordering of the axes is slightly unusual to my way of thinking. For example suppose m=.i.3 3 3 is the “cube" be sliced and v is your verb. Then the items of (0 v m) has successive items “going back” into the cube. The items (1 v m) are the horizontal slices. The items of (2

Re: [Jprogramming] Rank difficulties

2023-09-06 Thread Piet de Jong
Getting close. But wish I could avoid the annoying “column” vectors on some of the slices. This would be an annoying hurdle in the further slice processing. > On 7 Sep 2023, at 08:50, 'robert therriault' via Programming > wrote: > > Is this closer to what you are looking for Piet? > >

Re: [Jprogramming] Rank difficulties

2023-09-06 Thread 'robert therriault' via Programming
Is this closer to what you are looking for Piet? [n=: i. 3 3 3 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 slice=: ;@{"]: 0 (2 slice) n 0 1 2 9 10 11 18 19 20 1 (2 slice) n 3 4 5 12 13 14 21 22 23 2 (2 slice) n 6 7 8 15 16 17 24 25

Re: [Jprogramming] Rank difficulties

2023-09-06 Thread Henry Rich
Since you want all the slices, what you are looking for is a transpose. Maybe ~.@(, i.@#) |: ] Untested. Henry Rich On Wed, Sep 6, 2023, 6:10 PM Piet de Jong wrote: > Here is my “wish" > > A dyadic (tacit) verb such that x v y gives all the slices of y along > dimension x, where x is integer

Re: [Jprogramming] Rank difficulties

2023-09-06 Thread Piet de Jong
Here is my “wish" A dyadic (tacit) verb such that x v y gives all the slices of y along dimension x, where x is integer. That is to say i{ x v y is slice i of the array y along dimension x. Thanks for all your help! > On 7 Sep 2023, at 08:04, 'robert therriault' via Programming > wrote:

Re: [Jprogramming] Rank difficulties

2023-09-06 Thread 'robert therriault' via Programming
Or something like this? [n =. i. 2 2 2 0 1 2 3 4 5 6 7 ,./ n 0 1 4 5 2 3 6 7 ($ $ (,@,./)) n 0 1 4 5 2 3 6 7 Cheers, bob > On Sep 6, 2023, at 14:49, 'robert therriault' via Programming > wrote: > > Hi Piet, > > Maybe show us what you would want to do with higher dimensions? Or a

Re: [Jprogramming] Rank difficulties

2023-09-06 Thread Piet de Jong
I’m looking for a verb that does the relevant slicing. Hopefully the verb can be used to slice on any dimension. > On 7 Sep 2023, at 07:26, Brian Schott wrote: > > Does this help? > > ,./0 1 {"1 m > 0 2 > 1 3 > > > -- > (B=) <-my sig > Brian Schott > --

Re: [Jprogramming] Rank difficulties

2023-09-06 Thread 'robert therriault' via Programming
Hi Piet, Maybe show us what you would want to do with higher dimensions? Or a less symmetric 2 dimensional shape? For shape 2 2, I would use the even simpler |: m 0 2 1 3 Hope this helps. Cheers, bob > On Sep 6, 2023, at 14:26, Brian Schott wrote: > > ,./0 1 {"1 m ---

Re: [Jprogramming] Rank difficulties

2023-09-06 Thread Brian Schott
Does this help? ,./0 1 {"1 m 0 2 1 3 -- (B=) <-my sig Brian Schott -- For information about J forums see http://www.jsoftware.com/forums.htm