I find the boxed form or the linear form better to follow than the tree form- at least as present. I also find putting some things such as this into a script tool box- often in different forms -with lots of NB. does help. rms does involve fewer concepts and is easier to read but I welcome the added concepts involved in RMS -as I have learned about &. and &: differences and why (same for @ and @: ) and this is a bonus of this exercise. I am sure that I will be back often when I try and fail to understand something. J is great but there are so many ways to do things and so many nuances, it has a steep learning curve and I am an old dog ( an APL background, not used for some time, helps but It must be harder yet for C users).

Don Kelly

Thanks to all (and I expect that I will be back for more advice from experts
On 18/11/2013 8:03 AM, Linda Alvord wrote:
     RMS=: (+/ % #)&.:*:
5!:4 <'RMS'
              -- / --- +
         -----+- %
-- &.: -+    L- #
         L- *:
rms=:[:%:[:(+/%#)*: 5!:4 <'rms'
   -- [:
   +- %:
--+    -- [:
   │    │    -- / --- +
   L----+----+- %
        │    L- #
        L- *:
rms has a nice tree, and fewer concepts are required.

Linda


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Don Kelly
Sent: Monday, November 18, 2013 2:06 AM
To: [email protected]
Subject: Re: [Jprogramming] Novice problem

You sent an answer to my question before I asked it!  Thanks- I suspected
but didn't know  that this was it.

I think that I will stay with the earlier definition:

rms=:[:%:[:(+/%#)*:
which, while it does have brackets is somewhat more readable for my present
state of understanding. Yours is shorter and I expect it would be faster.
Now all of you have given me enough to digest for now.
Don

On 17/11/2013 7:23 AM, Raul Miller wrote:
Here's another definition of rms

     Rms=: +/@:*: %:@% #
     Rms 1 2 1 2
1.58114

Explanation:

We do not need to square the numbers in the argument to #, we only
need to square them in the argument to +/

We only need the square root on the result of %

Makes sense?

Also, here's a partial explanation for the (+/%#)&.:*: definition of
RMS

&.: means "under" much like &. except that the derived verb has
infinite rank - the verb on the left gets the entire array which
resulted from the verb on the right, regardless of the rank of the
verb on the right. In other words, it is equivalent to (+/ % #) &.
(*:"_)  In other words: square the numbers, add them up, divide by
their sum, then do the inverse of squaring on the result.

Thanks,

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
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