I guess the sentence  
if. 0 do. 1 end.
actually evaluated to i.0 0 which becomes the last value for the entire T
block.

Срд, 03 Ноя 2010, Henry Rich писал(а):
> I don't think there is any such thing as an 'empty sentence'.  T blocks 
> containing no sentences are true, but a blank line (which would surely 
> be an empty sentence, no?) does not become true:
> 
>     t =: 3 : 0
> if.
> 0
> 
> do. 1 else. 2 end.
> 
> )
>     t ''
> 2
> 
> 
> What I am trying to do is something akin to C's left-to-right && .
> 
> if.
>    if. (thing exists) do.
>      test that thing has desired property
>    end.
> do.
>    NB. code here executed if thing exists & has the desired property
> end.
> 
> I can work around it.
> 
> Henry Rich
> 
> 
> On 11/3/2010 8:45 PM, Raul Miller wrote:
> > On Wed, Nov 3, 2010 at 6:16 PM, Henry Rich<[email protected]>  wrote:
> >> tvb =: 3 : 0
> >>    if. 0 do.
> >>      0
> >>    elseif. 0 if. 0 do. 1 end. do.
> >>      1
> >>    elseif. do.
> >>      2
> >>    end.
> >> )
> >>     tvb ''
> >> 1
> >>
> >> I was expecting 2.
> >
> > This looks odd, but I am not sure it is a bug:
> >
> > You have an empty sentence after the nested if
> > sentence, and I think empty sentences are treated
> > as true.
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to