A has a shape! A has the same shape that 7 has.

It's the empty shape.

Understanding the empty shape is perhaps the most important lesson a J
programmer can ever learn.

   $7

   */$8
1
   +/$9
0

The empty shape is the reason we have a concept of identity values
associated with our verbs.

The empty shape is to arrays what zero is to numbers. It's the simplest
absence of anything that you can have. Its a space waiting to be filled. In
a sense, it represents J waiting for you to give it something worth doing.

As for inventing the left argument to {:: you just count from left to right
in each box.

And, if you get an error, that means you guessed the rank wrong. You can
either experiment (there are not many likely ranks) or you can compose an
expression to inspect the rank (or shape) of the suspect box.

And, just for fun, here's an empty list of empty array jokes:

Thanks,

-- 
Raul



On Sun, Mar 9, 2014 at 2:33 PM, Linda Alvord <[email protected]>wrote:

>  I’ve used 5!:4 ,  3!:2 and  3!:6  but not  5!:1  so here are two
> questions:
>
>     g=: 13 :'4*& y'
>    g
> 3 : '4*& y'
>
>   ]A=: 5!:1 <'g'
> ┌─────────────────────┐
> │┌─┬─────────────────┐│
> ││:│┌─────┬─────────┐││
> ││ ││┌─┬─┐│┌─┬─────┐│││
> ││ │││0│3│││0│4*& y││││
> ││ ││└─┴─┘│└─┴─────┘│││
> ││ │└─────┴─────────┘││
> │└─┴─────────────────┘│
> └─────────────────────┘
>    $A
>
>
> Why doesn’t  A  have a shape?
>
>    j=: 13 :'('''';1;1;1) {:: y'
>    j 5!:1 <'g'
> 4*& y
>
> How did you know how to invent  j  so it would extract the definition?
>
> Linda
>
> -----Original Message-----
> From: [email protected] [mailto:
> [email protected]] On Behalf Of Raul Miller
> Sent: Sunday, March 09, 2014 12:11 PM
> To: Programming forum
> Subject: Re: [Jprogramming] Oddities in Bond including ,:
>
> Here's your definition of g:
>
>    g=: 13 :'4*& y'
>
> Here's the atomic representation:
>
>    5!:1<'g'
> ┌─────────────────────┐
> │┌─┬─────────────────┐│
> ││:│┌─────┬─────────┐││
> ││ ││┌─┬─┐│┌─┬─────┐│││
> ││ │││0│3│││0│4*& y││││
> ││ ││└─┴─┘│└─┴─────┘│││
> ││ │└─────┴─────────┘││
> │└─┴─────────────────┘│
> └─────────────────────┘
>
> So let's try extracting the part that corresponds to the ,: part of your
> tree display:
>    (0;1;1;1) {:: 5!:1<'g'
> |length error
>
> Oops...
>
>    ('';1;1;1) {:: 5!:1<'g'
> 4*& y
>
> There we go. So what shape is it?
>
>    $('';1;1;1) {:: 5!:1<'g'
> 1 5
>
> Hmm... so how might we reproduce that shape at the command line?
>
>    $,:'4*& y'
> 1 5
>
> Bingo!
>
> In APL, there was a quadCR primitive which, given the name of a function
> (verb) would come back with the character representation of the definition
> of that verb. This character representation was an 2 dimensional array of
> characters. (I also remember a quadVR primitive which came back with a
> vector representation.)
>
> I imagine that that quadCR concept influenced the design, here. Underlying
> it is the idea of using fixed width fonts to simplify the task of
> organizing text vertically.
>
> And that's probably far enough on that tangent?
>
> Thanks,
>
> --
> Raul
>
> On Sun, Mar 9, 2014 at 11:26 AM, Linda Alvord <[email protected]
> >wrote:
>
> > Thanks Raul and Kip,  Here is how I should have written the four verbs:
> >
> > NB.  m&v y is defined as m v y
> > NB. u&n y  is defined as y u n
> >
> >    f=: 13 :'4&* y'
> >    g=: 13 :'4*& y'
> >    h=: 13 :'&*4 y'
> >    i=: 13 :'*&4 y'
> >
> >    f
> > 4&*
> >    g
> > 3 : '4*& y'
> >    h
> > 3 : '&*4 y'
> >    i
> > *&4
> >
> >    5!:4 <'f'
> >       -- 4
> > -- & -+- *
> >    5!:4 <'g'
> >       -- 3
> > -- : -+- ,:'4*& y'
> >    5!:4 <'h'
> >       -- 3
> > -- : -+- ,:'&*4 y'
> >    5!:4 <'i'
> >       -- *
> > -- & -+- 4
> >
> >    f 5
> > 20
> >    g 5
> > |syntax error: g
> > |       4*&y
> >    h 5
> > |syntax error: h
> > |       &*4 y
> >    i 5
> > 20
> >
> > My remaining question is about the trees for  g  and  h  .  How did  the
> > ,:  show up in the trees?  What does it mean?  Is it a signal that there
> is
> > a syntax error?
> >
> > Linda
> >
> >
> > -----Original Message-----
> > From: [email protected]
> > [mailto:[email protected]] On Behalf Of km
> > Sent: Sunday, March 09, 2014 12:46 AM
> > To: [email protected]
> > Subject: Re: [Jprogramming] Oddities in Bond including ,:
> >
> > A suggestion: where do the understood parentheses go in  4&*y  and in
>  4*&y
> > ?  --Kip
> >
> > Sent from my iPad
> >
> > > On Mar 8, 2014, at 10:33 PM, "Linda Alvord" <[email protected]>
> > wrote:
> > >
> > > Why is the display of  f  different than  g , h and I ?
> > >
> > >    NB.  m&v y is defined as m v y
> > >
> > >   NB. u&n y  is defined as y u n
> > >
> > >    f=: 13 :'4&*y'
> > >
> > >   g=: 13 :'4*&y'
> > >
> > >   h=: 13 :'y&*4'
> > >
> > >   i=: 13 :'y*&4'
> > >
> > >   f
> > > 4&*
> > >
> > >   g
> > > 3 : '4*&y'
> > >
> > >   h
> > > 3 : 'y&*4'
> > >
> > >   i
> > > 3 : 'y*&4'
> > >
> > >   5!:4 <'f'
> > >      -- 4
> > > -- & -+- *
> > >
> > >   5!:4 <'g'
> > >      -- 3
> > > -- : -+- ,:'4*&y'
> > >
> > >   5!:4 <'h'
> > >      -- 3
> > > -- : -+- ,:'y&*4'
> > >
> > >   5!:4 <'i'
> > >      -- 3
> > > -- : -+- ,:'y*&4'
> > >
> > > Where does  ,:  come from  in the trees for  g , h and I ?
> > >
> > >
> > >   f 5
> > > 20
> > >
> > >   h 5
> > > 20
> > >
> > >   g 5
> > > |syntax error: g
> > > |       4*&y
> > >
> > >   i 5
> > > |syntax error: i
> > > |       y*&4
> > >
> > > Finally,  only two work.
> > >
> > > Linda
> >
> ----------------------------------------------------------------------
> 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

Reply via email to