Katrina - this looks like this may be a useful extension of the work done at the end of this essay: https://code.jsoftware.com/wiki/Array_Thinking . Please keep us informed if you extend it further.
Elijah - I suspect Ken may be to blame for the axis specification. It would appear that J's rank ideas reflect his more recent thinking on this. On Fri, Oct 15, 2021 at 5:51 AM Katrina Scialdone <[email protected]> wrote: > I'm aware of ,: for homogeneous lists =) The main reason I was searching > for a solution and > eventually found <"0&> was specifically to deal with non-homogeneous lists > (such as a string > and two lists of numbers), as well as to deal with arbitrary numbers of > lists easily. The > manual alternative I found and was seeking to optimize was something along > the lines of this > (potential forks aside): > > (<"0 input) , (<"0 parens input) ,: (<"0 depthOf input) > > The dictionary example you linked is quite interesting! The 'table' > definition in profile > implements something similar which I've used before. I'm guessing it's a > more recent addition > than that dictionary page? > > */~ table 1+i.5 > ┌───┬─────────────┐ > │*/~│1 2 3 4 5│ > ├───┼─────────────┤ > │1 │1 2 3 4 5│ > │2 │2 4 6 8 10│ > │3 │3 6 9 12 15│ > │4 │4 8 12 16 20│ > │5 │5 10 15 20 25│ > └───┴─────────────┘ > > ~ Katrina > > On 10/15/21 3:32 AM, Elijah Stone wrote: > > > On Fri, 15 Oct 2021, Katrina Scialdone wrote: > >> <"0&> input ; (parens input) ; (depthOf input) > > NB. you can remove redundancies here using a fork: > > <"0&> (] ; parens ; depthOf) input > >> Its behavior is quite similar to ,[0.5] in Dyalog APL, which was the > >> inspiration for finding a J equivalent. > > If your lists are homogenous, you can use ,: instead: > > x=. i.5 > > y=. -x > > z=. *:x > > w=. -:x > > x , y , z ,: w > > 0 1 2 3 4 > > 0 _1 _2 _3 _4 > > 0 1 4 9 16 > > 0 0.5 1 1.5 2 > > (Whoever thought the axis operator was a good idea, I have no idea... :) > >> Is this a known technique, and is there a common name for this? > > I don't know of a specific name for it, but using boxes to format tables > > is definitely common. > > The dictionary uses something similar to demonstrate the 'table' adverb > > (https://www.jsoftware.com/help/dictionary/intro03.htm). > > -E > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Devon McCormick, CFA Quantitative Consultant ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
