Yes. All tacit expressions are trains (forks or hooks or a single verb phrase).
Yes to this too: %:(+/%#)*: 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 %: The technique you used with @: made the entire expression into a single verb phrase. It is a fairly straightforward but can force extra parentheses, and it requires that all verbs to the left of the rightmost @: be monadic. The [: technique is worth understanding. rms=:[:%:[:(+/%#)*: There is a 5 element fork. The right most 3 are evaluated first. The 3rd verb [: makes the 2nd (mean) which would normally be evaluated dyadically in its position (and so not work as intended) be evoked monadically instead. the 5th verb is needed to prevent the whole expression of being interpreted as a hook (with %: 4th verb as the dyad pivot), and to apply the 4th verb monadically to the result of the first 3. these pages may be useful: http://www.jsoftware.com/jwiki/PascalJasmin/Use%20Forks%20Instead%20of%20Hooks http://www.jsoftware.com/jwiki/PascalJasmin/Advanced%20forks%20and%20grammar ----- Original Message ----- From: Don Kelly <[email protected]> To: "[email protected]" <[email protected]> Cc: Sent: Saturday, November 16, 2013 8:20:04 PM Subject: [Jprogramming] Novice problem 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 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
