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 7 Sep 2023, at 10:57 am, 'Rob Hodgkinson' via Programming > <programm...@jsoftware.com> wrote: > > 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 1 > 2 3 > > T=:{{((i. $ $ y)-.x) |: y}} NB. Generalised 0 1 2 to (i. Rank y) > > 0 1{1 T a > 0 1 2 3 > 12 13 14 15 > > 4 5 6 7 > 16 17 18 19 > > 0 1{1 T b NB. Your original function failed > here on rank 2 > 0 2 > 1 3 > > TT=:13 : '((i. $ $ y)-.x) |: y’ > TT > ] |:~ [ -.~ [: i. [: # [: $ ] > > 0 1{1 TT a > 0 1 2 3 > 12 13 14 15 > > 4 5 6 7 > 16 17 18 19 > > 0 1{1 TT b > 0 2 > 1 3 > > > Impressive solution Ben (strong scent of APL in there !)… well done. > > Piet does this do what you want ? > > Best, Rob > >> On 7 Sep 2023, at 10:22 am, Ben Gorte <bgo...@gmail.com> wrote: >> >> 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 =: {{ (0 1 2-.x) |: y }} >> >> >> (sorry, not tacit) >> >> >> Ben >> >> On Thu, 7 Sept 2023 at 09:58, Piet de Jong <pietd...@gmail.com> wrote: >> >>> 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 v m) are the vertical slices. >>> >>> 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. >>> >>>> On 7 Sep 2023, at 08:32, Henry Rich <henryhr...@gmail.com> wrote: >>>> >>>> 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 <pietd...@gmail.com> 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. 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 < >>>>> programm...@jsoftware.com> wrote: >>>>>> >>>>>> 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 < >>>>> programm...@jsoftware.com> wrote: >>>>>>> >>>>>>> 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 <schott.br...@gmail.com> >>> wrote: >>>>>>>> >>>>>>>> ,./0 1 {"1 m >>>>>>> >>>>>>> ---------------------------------------------------------------------- >>>>>>> For information about J forums see >>> http://www.jsoftware.com/forums.htm >>>>>> >>>>>> ---------------------------------------------------------------------- >>>>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>>> >>>>> ---------------------------------------------------------------------- >>>>> For information about J forums see http://www.jsoftware.com/forums.htm >>>>> >>>> ---------------------------------------------------------------------- >>>> For information about J forums see http://www.jsoftware.com/forums.htm >>> >>> ---------------------------------------------------------------------- >>> For information about J forums see http://www.jsoftware.com/forums.htm >>> >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm