On Tue, Mar 23, 2010 at 7:30 PM, Sprague, Webb (OFM)
<[email protected]> > 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.

As others have suggested, you should find out the answers
to your questions through experimentation.

For example, consider the following:

   3 :'if.y do.1 else.0 end.' 1 0 0
1
   3 :'if.y do.1 else.0 end.' 0 1 0
0
   3 :'if.y do.1 else.0 end.' i.3 3
0
   3 :'if.y do.1 else.0 end.' 2+i.3 3
1

Here, I wanted to illustrate the meaning of if. so
I created a short sentence to test it, and I
used it and some variations to see how it
works for some typical cases.

> 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)

You seem to be beyond this point now, but the
above sentence was equivalent to

   'return value:', (rtn 1!:2(2))

> Finally, if there is a way to unbox a variable, it would be great to
> hear about it.

A google search of
   site:jsoftware.com unbox
gives for one of its hits
   http://www.jsoftware.com/help/jforc/contents.htm

I imagine that book would be a good place to start for a lot of
your questions (and of course searching down the page for
"unbox" and following that link would have been immediately
relevant).

That said, the variable itself will stay boxed until you
update the name with a new value (and then whether it
is boxed or not would depend on that new value).

On Wed, Mar 24, 2010 at 2:59 PM, Sprague, Webb (OFM)
<[email protected]> > In > the languages I am familiar with
there would need to be an "==" or
> some such in there.  Is "element of" like a Boolean?

In J, the primitives which most closely match the == which
various other languages use are = and -: (= and -: differ in their
handling of structure, but == mostly ignores structure -- in most
languages which I have encountered, == compares structure
references instead of values, so I could not say whether
= or -: would be closer to what you might be thinking of).

Anyways, as others have commented, e. produces boolean
results (as does = and -: and various other operations).

But, just as == is not a boolean in any language I have
encountered, e. and so on are not booleans in J.

Also, in J, =: and =. serve approximately the same roles
that = serves in other languages.

FYI,

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to