> Although,  '' + 2 is not an error or 2, but it reads "empty + 2",
> which I though would be 2. Hmm.

A different explanation is involved with this one.
Basically, for a dyadic function (such as +) 
with ranks 0 0, if one argument is an atom, 
then the result has shape (and rank) of the
other argument. A detailed explanation starts 
from + having ranks 0 0 and then follows from 
the general mechanism of function application.



----- Original Message -----
From: Matthew Brand <[email protected]>
Date: Thursday, April 2, 2009 9:49
Subject: Re: [Jprogramming] trivial reshaping question
To: Programming forum <[email protected]>

> Thanks, that works.
> 
> I had not come across ''$d.  When I look at '' I think of 
> an empty
> literal but it must count as empty "anything". I guess that fits
> because if I want a loop that appends numerical results to a 
> list, I
> initialize it with ''.
> 
> e.g.
> 
> r =. ''
> for_i. i. 10 do.
>   r =. r , *: i
> end.
> 
> ''$ at first glance feels like it should not work since '' is not
> really a number. But then again ''$y reads as "make y into shape x
> where x is empty, i.e. make it into an empty shape" and, $ ''$y is
> indeed ''.
> 
> I guess I should have said to myself that I want to make y have empty
> shape, and then ''$ would have followed naturally!
> 
> Although,  '' + 2 is not an error or 2, but it reads "empty 
> + 2",
> which I though would be 2. Hmm.
> 
> 
> On Thu, Apr 2, 2009 at 5:22 PM, Roger Hui <[email protected]> wrote:
> > Use   0{d   or   ''$d
> >
> >
> >
> > ----- Original Message -----
> > From: Matthew Brand <[email protected]>
> > Date: Thursday, April 2, 2009 9:19
> > Subject: [Jprogramming] trivial reshaping question
> > To: Programming forum <[email protected]>
> >
> >> Something simple ... and a bit trivial I am stuck on ...
> >>
> >> d =. 1$1
> >>    d 0} 1 2 3
> >> |rank error
> >>
> >> What can I do to d to make its shape fit into 0} 1 2 3?
> >>
> >> e.g.
> >> (,d) 0} 1 2 3
> >> |rank error
> >> |   (,d)    0}1 2 3
> >>
> >> Does not work. Could somebody suggest what to use instead of ,
> >> to make
> >> this work?
> >> --------------------------------------------------------------
> ---
> >> -----
> >> For information about J forums see 
> http://www.jsoftware.com/forums.htm>>
> > ---------------------------------------------------------------
> -------
> > For information about J forums see 
> http://www.jsoftware.com/forums.htm>
> 
> 
> 
> -- 
> http://www.ixquick.com/
> 
> Ixquick Protects Your Privacy!
> The only search engine that does not record your IP address.
> 
> http://www.vivapalestina.org/
> -----------------------------------------------------------------
> -----
> 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