e. means 'element of'
<'NO'
is an atom, one box containing a string.
rtn e. <'NO'
will check each atom of rtn to see if the atom is
<'NO'
and if there are no atoms in rtn, or if the first one is <'NO',
the test will be declared true.
To print, try
('return value:' , >rtn) 1!:2 (2)
(which shows you how to unbox a noun)
or
load 'printf' NB. Do this just once per session
'return value: %s' printf <rtn
Henry Rich
Sprague, Webb (OFM) wrote:
> Hi all,
>
> Forgive my newbieness,... but what does the following snippet mean (from
> some J code that it is now my responsibility to maintain):
>
> if. rtn e.<'NO' do.
>
> I understand "if." And "do.", just not the part in the middle; I assume
> it has something to do with testing for equalituy. "rtn" is the value
> given by a window interface thingy.
>
> On a related note, I would like to print a string with the value of
> return and some text concatenated to it, but the following snippet gives
> me a "domain error"
>
> 'return value:', rtn 1!:2(2)
>
> I think rtn might be boxed, or something, but I can't figure it out. If
> it were a C-ish language, I would be writing "printf("return value: %s",
> rtn);".
>
> Finally, if there is a way to unbox a variable, it would be great to
> hear about it.
>
> Thanks!
>
> ---
> W. Webb Sprague
> Forecast Analyst
> Office of Financial Management, Forecast Division
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm