I have been trying to think up a useful response here, but I just do not
know enough from this description to make good choices.

Typically, I build up the expressions that I find useful first and then
come up with names for them later.  Sometimes I re-arrange things that work
so that they are easier for me to describe.\

And, yes, it's easy to transform between different array representations.
 But there's a lot of representations and a lot of transformations between
them and a lot of ways of using each representation, so it's hard to give
specific advice.  (As a general rule though, I try to arrange things so
that they are simple.)

And, yes, putting each "column" in its own variable can be a good approach.

-- 
Raul

On Thu, Nov 17, 2011 at 5:25 PM, Daniel Lyons <[email protected]>wrote:

> On Thu, Nov 17, 2011 at 09:49:32AM -0500, Raul Miller wrote:
> > In general, structuring J code is an exercise in picking the right words.
>
> Well, in case you can help with that, here's my situation. For this
> particular problem, I need to calculate a distance, so I have an
> origin and a destination. Each of those has a pair of numbers
> associated with it. In this particular problem, I'm not so much
> interested in the actual distance as the time it would take a dish to
> move to the new position, and since it can rotate and rise
> simultaneously, I can treat the two values separately and then take
> whichever is larger as the time it would take.
>
> In another setting, I would be inclined to say, alright, so I need a
> way to package up a right ascension and a declination so I can
> operate on both simulatenously. And I think that would probably work
> here as well, but:
>
> 1. I suspect it would be more idiomatic J to say, I have an array of
> right ascensions, an array of declinations, let's produce an array of
> times to move for each axis and then combine both with maximum to
> produce an array of the actual time to move.
>
> 2. In attempting to treat a pair of boxed values as a single value and deal
> in terms of arrays of those, I think I'm tripping over boxing and rank
> at the same time. There's probably a reason this topic is reserved for
> later chapters in JfC. Errors in J are not easy to debug if you're
> doing too much in one line, and without really understanding what's
> going on I'm sure I'm bumping into situations where what I really need
> to do is nest the operation in some kind of unbox/rebox.
>
> The only thing that concerns me about going with N arrays of unboxed items
> versus one array of N boxed items is that my input file looks more
> like the latter. But it must not be terribly hard to pull each column
> out into its own variable, if that's the idiomatic thing to do.
>
> Anyway, thanks for all your help! My intent is to keep hammering at
> JfC and LJ and trying different things until I find I am making
> progress, and coming here whenever I'm surprised.
>
> --
> Daniel Lyons
> ----------------------------------------------------------------------
> 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