This is a novice problem (which arose from reading "Easy J" by Linda Alvort I think that I have it worked out but this is something (IMHO) that possibly should be in a primer. I have occasion to use what is called rms or root mean square (usually applied to a wave form).
I can define root, mean and square and can do something like:
root mean square 1 2 1 2
or
%:(+/%#)*: 1 2 1 2 NB. in immediate execution
1.58114                                 OK

A natural tendency equivalent to saying mean=: +/%#
is to try
rms=: %:(+/%#)*:
But rms 1 2 1 2 fails.
However rms=: 3: ' %:(+/%#)*:y'  or rms=: 13: ' %:(+/%#)*:y'
  is OK
and the latter is equivalent to
rms=:[:%:[:(+/%#)*:  which works

Alternatively  rms=:%:@:(+/%#)@:*:    also works

It is obvious that either the capped fork (from use of 13: or use of @: work and I see the reasoning behind this- forcing a sequential " root after mean after square".

Am I right in assuming that immediate execution of
%:(+/%#)*:   y where y is explicitly entered
is treated as 3: or 13: ' %:(+/%#)*::y ' (explicitly in that the *:y is the argument for mean(+/%#) whose value is the argument for %: i.e. as in APL for which 'tacit' doesn't exist) and rms=: %:(+/%#)*: as a tacit verb with no argument is parsed as a fork rather than sequentially as desired and runs into never never land?

The classic example of 'mean=:+/%# as a verb is misleading in that the example is a single fork, but trying to extend it
does need a flag as to the need to emphasize the parsing.
(+/%#) *: 1 2 1 2 works but msg =:(+/%#)*: doesn't work but msg=:(+/%#)@:*: or msg=:[:(+/%#)*: do work


Don Kelly

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

Reply via email to