One rephrasing would be: vec=: (1 2 */@:o. ]) , (1 */@:o. ]) , 2 o. }:
This carries what I think is a rational assumption (that the argument will always have two items). Sadly, there's no argument to o. which gives a constant 1 result for the expected arguments or this could be simplified quite a bit more. Still, maybe this is good enough? Thanks, -- Raul On Sat, Jan 6, 2018 at 5:07 PM, Jerry <[email protected]> wrote: > I am a relative newbie and am trying to teach myself the intricacies by > addressing a simple problem: some geometric operations on the surface of a > unit sphere. The first step is to take latitude and longitude angles and > create a Cartesian vector pointing from the center of the sphere to that > point. I can do that via: > > vec =: ((1 o. }:)*(2 o. {:)),((1 o. }:)*(1 o. {:)),(2 o. }:) > > this verb yields the desired vector > > [vec o. (1.25,_0.55) > > 0.110616 0.698401 _0.707107 > > +/([vec o. (1.25,_0.55))^2 > > 1 > > Is there a shorter, less verbose way of writing the verb 'vec'? > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
