Raul. Wow! I never realized what the dyadic use of "-." (less) would do. That is really neat. Plus I keep forgetting that insert will work with all kinds of verbs, not just + * >. and the other usual primitive suspects.
However I'm still trying to wrap my head around this: ([-.-.)/a So I tried some experiments: ]a =: ?6 12$10 9 1 6 9 3 1 7 7 6 4 6 4 3 1 5 8 8 5 4 7 7 5 2 5 6 7 1 7 5 7 1 4 4 6 1 4 9 1 5 2 0 7 6 6 2 9 5 1 6 9 9 8 3 1 8 2 0 7 1 4 9 7 9 1 1 8 1 2 1 5 1 6 >./([-.-.)/a 7 <./([-.-.)/a 1 NB. Yes, the whole thing works as advertised. NB. So let's deconstruct it: ([-.-.)/a 1 1 7 7 NB. So this clearly finds all the common integers across all the rows. NB. But why are there two ones and two sevens? There is only NB. one one in the second row, and three sevens in the third row. NB, And only one seven in the fourth, fifth, sixth, and seventh row. NB. So let's see what happens if we remove the parenthesis: [-.-./a _8 _5 _8 _5 _3 _5 _3 NB. Whoa! Seven numbers?? There are 6 rows and 12 columns. What happened? NB. Let's try this... -.-./a _8 _5 _8 _5 _3 _5 _3 NB. So the square bracket doesn't make any difference. -. 9 1 6 9 3 1 7 7 6 4 6 4 NB. try on the first row of matrix a _8 0 _5 _8 _2 0 _6 _6 _5 _3 _5 _3 NB. That looks a little bit like the previous result with no parenthesis. NB. Well, that's just what the Vocabulary says will happen (-.y is 1-y): 1 - 9 1 6 9 3 1 7 7 6 4 6 4 _8 0 _5 _8 _2 0 _6 _6 _5 _3 _5 _3 NB. So now we put the scan back in: -./ 9 1 6 9 3 1 7 7 6 4 6 4 9 NB. That makes sense, since: 9-.1-.6-.9-.3-.1-.7-.7-.6-.4-.6-.4 9 NB. Let's try two -.s -.-./ 9 1 6 9 3 1 7 7 6 4 6 4 _8 NB. That makes sense, since -. 9 -> _8 But I still can't figure out what scan is doing to the noun a. Skip (-.-.)/a 9 1 6 9 3 1 7 7 6 4 6 4 Skip Cave Cave Consulting LLC On Fri, Sep 1, 2017 at 2:21 AM, Raul Miller <rauldmil...@gmail.com> wrote: > If it exists, >./([-.-.)/a will find the largest integer common to all > of the rows. (If it does not exist, it will give you __ which is the > identity element for "largest". In other words, __ >. x always returns > x). > > To get the smallest replace >. with <. > > In other words, first find the intersection of all rows, then find the > largest (or smallest) number in that intersection. > > Thanks, > > -- > Raul > > > On Fri, Sep 1, 2017 at 2:48 AM, Skip Cave <s...@caveconsulting.com> wrote: > > This wasn't a Quora problem, though I needed to solve this as part of the > > solution to a different problem. > > > > Given the random integer matrix: > > > > ]a =: 6 12$ ?72$10 > > > > 2 3 6 6 5 8 3 7 4 9 0 8 > > > > 1 9 4 1 7 3 1 8 2 5 2 7 > > > > 4 7 4 7 6 4 1 1 4 6 6 8 > > > > 5 8 0 0 3 1 8 3 0 7 3 3 > > > > 4 4 7 3 2 4 7 5 7 3 3 9 > > > > 3 8 4 1 3 7 8 7 5 6 9 9 > > > > > > What J expression will find the largest integer that is common to all > > > > of the rows? In this specific case, the answer is 7. > > > > What about the smallest integer that's common in all rows? > > > > > > Skip > > ---------------------------------------------------------------------- > > 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