
Chapter 15: Tacit Operators15.1 IntroductionJ provides a number of builtin operators  adverbs and conjunctions. In Chapter 13 we looked at defining our own operators explicitly. In this chapter we look at defining adverbs tacitly.15.2 Adverbs from ConjunctionsRecall from Chapter 07 the Rank conjunction, ("). For example, the verb (< " 0) applies Box (<) to each rank0 (scalar) item of the argument.< " 0 'abc' ++++ abc ++++A conjunction takes two arguments. If we supply only one, the result is an adverb. For example, an adverb to apply a given verb to each scalar can be written as (" 0)
The scheme is, that for a conjunction C and a noun N, the expression (C N) denotes an adverb such that: x (C N) means x C NThe argument to be supplied to the conjunction can be a noun or a verb, and on the left or on the right. Altogether there are four similar schemes: x (C N) means x C N x (C V) means x C V x (N C) means N C x x (V C) means V C xThe sequences CN CV NC and CV are called "bidents". They are a form of bonding whereby we take a twoargument function and fix the value of one of its arguments to get a oneargument function. However, there is a difference between bonding a dyadic verb (as in + & 2 for example) and bonding a conjunction. With the conjunction, there is no need for a bonding operator such as &. We just write (" 0) with no intervening operator. The reason is that in the case of + & 2, omitting the & would give + 2 which means: apply the monadic case of + to 2, giving 2. However, conjunctions don't have monadic cases, so the bident (" 0) is recognised as a bonding. Recall the "Under" conjunction &. from Chapter 08 whereby f&.g is a verb which applies g to its argument, then f then the inverse of g. If we take f and g to be: f =: 'f' & , g =: >then we see that f is applied inside each box:
Now, using the form CV, we can define an adverb EACH to mean "inside each box":
15.3 Compositions of AdverbsIf A and B are adverbs, then the bident (A B) denotes an adverb which applies A and then B. The scheme is:x (A B) means (x A) B 15.3.1 Example: Cumulative Sums and ProductsThere is a builtin adverb \ (backslash, called Prefix). In the expression f \ y the verb f is applied to successively longer leading segments of y. For example:< \ 'abc' ++++ aababc ++++The expression +/ \ y produces cumulative sums of y: +/ \ 1 2 3 1 3 6An adverb to produce cumulative sums, products, and so on can be written as a bident of two adverbs: cum =: / \ NB. adverb adverb
15.3.2 Generating TrainsNow we look at defining adverbs to generate trains of verbs, that is, hooks or forks.First recall from Chapter 14 the Tie conjunction (`), which makes gerunds, and the Evoke Gerund adverb (`: 6) which makes trains from gerunds. Now suppose that A and B are the adverbs: A =: * ` NB. verb conjunction B =: `: 6 NB. conjunction nounThen the compound adverb H =: A Bis a hookmaker. Thus <: H generates the hook * <: , that is "x times x1"
15.3.3 RewritingIt is possible to rewrite the definition of a verb to an equivalent form, by rearranging its terms. Suppose we start with a definition of the factorial function f. Factorial 5 is 120.f =: (* ($: @: <:)) ` 1: @. (= 0:) f 5 120The idea now is to rewrite f to the form $: adverb, by a sequence of steps. Each step introduces a new adverb. The first new adverb is A1, which has the form conj verb. A1 =: @. (= 0:) g =: (* ($: @: <:)) ` 1: A1 g 5 120Adverb A2 has the form conj verb A2 =: ` 1: h =: (* ($: @: <:)) A2 A1 h 5 120Adverb A3 has the form adv adv A3 =: (* `) (`: 6) i =: ($: @: <:) A3 A2 A1 i 5 120Adverb A4 has the form conj verb A4=: @: <: j =: $: A4 A3 A2 A1 j 5 120Combining A1 to A4: A =: A4 A3 A2 A1 k =: $: A k 5 120Expanding A: m =: $: (@: <:) (* `) (`: 6) (` 1:) (@. (= 0:)) m 5 120We see that m and f are the same verb:
This is the end of Chapter 15. 
The examples in this chapter
were executed using J version 701.
This chapter last updated 29 Jul 2012
Copyright © Roger Stokes 2012.
This material may be freely reproduced,
provided that this copyright notice is also reproduced.