Today I was executing code where I wanted to compare a rational to  a a
computed list of about 1.8 million rationals.  I wanted to be able to
specify two items as input to the program in y, so I coded

if. #y do. lim =. {. y else. lim =. 99r100 end.

and then I had a line where I was comparing it to a long running total of
booleans over a i.

As long as I allowed it to accept the default, the program worked, but when
I specified the value of y from the command line, y got a shape.  Then I got
a length error.  When I stopped the program in debug, I found that the way I
passed in y to lim, lim ended up having a shape - it was a 1 element array
and not a scalar. In order to compare it using =, I had to do the following:

, lim ="1 (step, 1) $

And that seemed like a lot of manipulation and jumping through hoops.

I did searches and other things, I am not sure I've read it anywhere, but I
think I've seen discussion of it, I just can't find it.

How do you "unarray" a thing?  Turn it back into a scalar?  Is it something
horrible like ".":  ?  I didn't think of that this afternoon, and I'm not
sure it would have worked.  I probably could have done %/ 2 x: since I
expected the input to be a rational, but I was drawing a blank at the
time...is there an official way to scrub the arrayness off of a variable?  A
way to reshape it that scrubs the shape?

-- 
Of course I can ride in the carpool lane, officer.  Jesus is my constant
companion.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to