Why do you say "Your x arguments all have atoms so, I'm sorry, I can't see their significance."?
What is different between the x values in my email message and the x values you originally specified? Thanks, -- Raul On Fri, Feb 5, 2016 at 5:42 AM, Matthew Baulch <[email protected]> wrote: > The 'x $ y' dyad, like you say, has rank 1 for x and _ for y. Examples > (1)-(3) have rank 0 arguments for x. The x arguments are arrays with > non-empty shape but no atoms in these cases. Your x arguments all have > atoms so, I'm sorry, I can't see their significance. My x arguments have > shapes containing only non-negative integers (as you mentioned), although > some are zero. I'm not sure what you mean by: > > "So your first example is not even going to get to the reshape part of the > operation. Your frame, which will hold your results, is empty." > > I understand and agree that the frame of the left argument is empty. That > doesn't surprise or concern me. What I don't understand are the reasons for > the result shapes in (1)-(3), and why the result for (3) has an atom. > > All verbs (that I can think of) with an argument of rank >= 1 are defined > also for arguments of rank 0. For instance, 'i. y', 'x # y' (x has rank > 1), and so on. Of course, there are very many verbs having arguments of > infinite rank too. Therefore, I don't see it as remarkable to apply a rank > 0 array as an argument to a verb with rank > 0. > > Your comment > > "the dictionary definitions for verbs mostly only deal with arguments which > fit within the dictionary defined rank for the verb" > > was enlightening and made me think. Is it simply that the case that most > verb definitions don't cover the case of rank 0 arguments with no atoms? > Perhaps my question relates to an undefined part of J? > > On Fri, Feb 5, 2016 at 7:27 PM, Raul Miller <[email protected]> wrote: > >> I'm going to go with the original vocab definition, because that's how >> I understand reshape. >> >> But also keep in mind that the left rank of reshape is 1. A shape is a >> (usually quite short) list of non-negative integers. This is something >> that we all have to go through - remembering that the dictionary >> definitions for verbs mostly only deal with arguments which fit within >> the dictionary defined rank for the verb. That's good enough for most >> purposes, when you need to concern yourself with rank it's the same >> rules for all verbs (except for the actual numeric values being >> different on some verbs). >> >> Perhaps http://www.jsoftware.com/help/dictionary/dictb.htm would be >> worth reviewing? >> >> Anyways, to see what that means for your reshape examples, consider this: >> >> <"1 x=: 1 0 1 $ 0 >> >> (that's an empty result - no boxes.) >> >> $<"1 x=: 1 0 1 $ 0 >> 1 0 >> >> (that's what your frame looks like, for this example.) >> >> So your first example is not even going to get to the reshape part of >> the operation. Your frame, which will hold your results, is empty. >> >> In your first example, x is empty, so you'll be using an array of >> fills (which are zeros) for the test run of reshape. So you actually >> do get a final dimension here - the last dimension is 1, and although >> x is empty, the interpreter uses that 1 to decide how many zeros it's >> going to use. >> >> Your second and third examples have the same issue - you're not doing >> a single reshape but a collection of reshapes. But in those examples >> your last dimension of x is zero. So when the interpreter does its >> test run on the verb to see what kinds of results it's getting instead >> of doing: >> >> (,0) $ 1 2 3 >> >> like it was in the first example, it is instead doing >> >> '' $ 1 2 3 >> 1 >> >> In other words there trial result doesn't have a shape, so you get one >> less dimension in your result than you had in x. >> >> As for your last example: >> >> <"1 x=: 1 $ 0 >> +-+ >> |0| >> +-+ >> $ <"1 x=: 1 $ 0 >> >> ...so your final example does do the reshaping, but you are reshaping >> with an empty shape, so you still get an empty result. >> >> Does this make sense? >> >> Thanks, >> >> -- >> Raul >> >> On Fri, Feb 5, 2016 at 3:06 AM, Matthew Baulch <[email protected]> >> wrote: >> > Original vocab says: >> > "The shape of x$y is x,siy where siy is the shape of an item of y." >> > >> > NuVoc says (for x $ y): >> > "If y is an atom or a list, the shape of the result is x", and "the shape >> > of [the result of x$y] is always x,}.$y". >> > >> > Let y =: 1 2 3 for all that follows. >> > >> > (1) >> > x =: 1 0 1 $ 0 >> > x$y has no atoms, shape 1 0 0 >> > (2) >> > x =: 1 0 0 $ 0 >> > x$y has no atoms, shape 1 0 >> > (3) >> > x =: 1 0 $ 0 >> > x$y has a single atom: 1, and shape 1 >> > (4) >> > x =: 1 $ 0 >> > x$y has no atoms, shape 0 >> > >> > Examples (1)-(3) appear to violate the definitions. Only example (4) >> > agrees. Can anyone shed some light on this? (3) strikes me as >> particularly >> > strange. I'm sure I must have missed something. >> > >> > My head is spinning! >> > ---------------------------------------------------------------------- >> > 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
