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

Reply via email to