
Chapter 11: Tacit Verbs ConcludedIn this chapter we consider some general points in writing expressions for tacit verbs. Here is an example of a tacit verb. It multiplies its argument by 3:
Recall from Chapter 03 that the bonding operator & produces a monad from a dyad by fixing one of the arguments of the dyad. The scheme is that if N is a noun and V a dyadic verb, then: (N & V) y means N V y (V & N) y means y V N We take the bonding operator & as an example of a typical operator, where arguments may be nouns or verbs. In general, N can be an expression denoting an noun, and V an expression denoting a verb. We look now at how these expressions get evaluated. The general rules are set out formally in Appendix 1 but here we take an informal first look at a few of the main points. 11.1 If In Doubt, ParenthesizeHere is another tacit verb. Its general form is V&N. It multiplies its argument by 5%4, that is, by 1.25
Are the parentheses around 5 % 4 necessary here? If we omit them, we see: SCALE =: * & 5 % 4 SCALE 1.25 so they evidently make a difference. SCALE is a number, not a verb. The result of 1.25 is produced by applying the verb *&5 to the argument % 4 (the reciprocal of 4)
We have a general rule: informally we can say that conjunctions get applied before adjacent verbs. Thus in the expression * & 5 % 4 the first step is to apply the & operator to its arguments * and 5. Why is the right argument of & just 5 and not 5%4? Because of another general rule: the right argument of a conjunction is as short as possible. We say that a conjunction has a "short right scope". (By contrast, we say that a verb has a "long right scope" to express what we earlier called the "rightmost first" rule for verbs. What about the left argument of an operator? An adverb or conjunction is said to have "long left scope", that is, as much as possible. For example, here is a verb z which adds 3 to the square of its argument. 3 plus the square of 2 is 7.
We see that the left argument of @: is the whole of 3&+. If we are in doubt in any particular case we can always make our intention clear. We can write parentheses around a part of an expression, that is, around a function  verb or operator  together with its intended argument(s). For example, verb z can be written with parentheses as:
Sometimes parentheses are necessary and sometimes not, but, let me emphasize, if in doubt, parenthesize. 11.2 Names of Nouns Are EvaluatedIn an expression of the general form N&V or V&N, the the names of any nouns occurring in N are evaluated right away. Here is an example of a function f to multiply by fivefourths. The numerical value is given as a%b where a and b are nouns.
We see that function f contains the computed number 1.25 so that a%b has been evaluated. 11.3 Names of Verb Are Not EvaluatedIn N&V the verbexpression V is not necessarily fully evaluated. If expression V is the name of a verb, then the name is enough:
11.4 Unknowns are VerbsWhen a new name is encountered, it is assumed to be a yettobedefined verb if it possibly can be.
Any sequence of hithertounknown names is assumed to be a train of verbs: Ralph Waldo Emerson Ralph Waldo Emerson Consequently, a verb can be defined in "topdown" fashion, that is, with detail presented later. For example, here is a CelsiustoFahrenheit converter presented topdown. ctof =: shift @ scale shift =: + & 32 scale =: * & (9 % 5)
We can see that ctof is defined solely in terms of (the names) scale and shift. Hence if we now change scale or shift we will effectively change the definition of ctof. ctof 100 212 scale =: * & 2 ctof 100 232 scale =: * & (9 % 5) ctof 100 212 The possibility of changing the definition of a function simply by changing one of its subordinate functions, may or may not be regarded as desirable. It is useful, in so far as we can correct a definition just by changing a small part. However, it may be a source of error: we may introduce a new verb, scale say, forgetting that scale is already defined as subordinate in ctof. There are ways to protect ctof against accidental redefinition of its subordinate functions. Firstly, we can put a wrapper of explicit definition around it, making scale and shift local, thus: CTOF =: 3 : 0 shift =. + & 32 scale =. * & (9 % 5) shift @ scale y ) CTOF 100 212 A second method is to, so to speak, "freezing" or "fixing" the definition of ctof, with the "Fix" adverb f. (letterf dot). Observe the difference between the values of the verbs ctof and (ctof f.)
We see that adverb f. applied to a tacit verb replaces names by definitions, giving an equivalent verb defined only in terms of builtin functions. Here is yet another definition of ctof. scale =: * & (9 % 5) shift =: + & 32 ctof =: (shift @ scale) f.
After this definition, the names scale and shift are still defined, but are no longer important in the definition of ctof. 11.5 Parametric FunctionsThe following example shows the consequences of nouns being evaluated and verbs not in an expression for a tacit verb. A curve may be specified by an equation such as, for example: y = lambda * x * (1  x) This equation describes a family of similar parabolic curves, and different members of the family are picked out by choosing different values for the number lambda. A function to correspond to this equation might be written explicitly as verb P: P =: 3 : 'lambda * y * (1y)' Here lambda is not an argument to function P, but a variable, a number, which makes a difference to the result. We say that lambda is a parameter, or that function P is parametric.
Now, can we write a tacit version of P taking lambda as a parameter? lambda is currently 3.5. If we now generate a tacit form of P tP =: 13 : 'lambda * y * (1y)' tP 3.5 * ] * 1  ] then we see that lambda is treated as a constant, not a parameter. This is not what we want. We try again, this time ensuring that lambda is not specified beforehand, by erasing it: erase <'lambda' 1 tP =: 13 : 'lambda * y * (1y)' tP [: lambda [: * ] * 1  ] Now we see that tP is a train of verbs, where lambda (being unknown) is assumed to be a verb. This assumption conflicts with the intended meaning of lambda as a number. Hence with lambda as a number, we get an error:
Whether or not lambda is specified in advance, it appears that a fully tacit exact equivalent to P is not possible. However we can come close. One possibility is to compromise on "fully tacit". Here tP is a train of verbs, where the first is explicitlydefined to deliver the value of lambda regardless of its argument.
Another possibility is to compromise on "exact equivalent". Here we take parameter lambda to be, not a number, but a constant function (see Chapter 09) which delivers a number. For example, a value for the parameter could be written as lambda =: 3.5 " 0 and tP could be defined as:
Now we can vary the parameter without redefining the function:
This is the end of Chapter 11 
The examples in this chapter
were executed using J version 601 beta.
This chapter last updated 18 May 2006 .
Copyright © Roger Stokes 2006.
This material may be freely reproduced,
provided that this copyright notice is also reproduced.