Essays/Tacit Expressions

From J Wiki
Jump to navigation Jump to search

A tacit expression is a sequence of J operations, which can be separated from its arguments. In other words, it preserves its features when put between parentheses or assigned to a name.

Tacit expressions is one of the pillars of J programming. They make possible functional programming of a special kind: not only stateless computation, but the one without variables.

Here we shall discuss, what features of J make up tacit expressions.


Introduction

To better understand the tacit facilities in J we will talk about the dataflow of evaluation in J. An expression always results in a single output. The input creates a number of cases: monadic has one argument, dyadic input has two. Typically, adverb can have up to three inputs, and conjunction up to four. However, adverbs and conjunctions may themselves produce adverbs and conjunctions thus resulting in expressions with arbitrary number of inputs.

   1 '2' 3 (2 : '2 : ''+''') 4 '5' 6   NB. six inputs
7

Sections of the dataflow also have different throughput capacities: ranks of data that can be passed at a time. As a result when passing through different sections, undergoing re-shaping, splitting and combining structural operations as well as boxing and opening, different amounts of data may follow separate paths, and reconstruct in different ways.

Building the Pipeline

We can think of the evaluation dataflow as a pipeline through which the data passes. The basic units of the pipeline are monadic and dyadic verbs. Monadic verb makes a straight section of the pipeline: one input and one output. Dyadic verb creates a join: two inputs result in one output. The higher order operations and trains serve as links in the pipeline that combine sections together and structure the pipeline in a number of ways: append two sections for sequential evaluation, branch the input sending the data along parallel paths, change the position of the inputs, or apply a section to parts of the input in a certain order or otherwise modify a section so that it is evaluated differently.

Reordering Input

Reflexive adverb u~ y branches the input and evaluates u dyadically.
Passive adverb x u~ y swaps the two streams of input.

Form Monad

Reflexive

Dyad

Passive

Rank
[x] u~ y
Essays tacit 1.png
Essays tacit 2.png
_ ru lu

Sequence

The following conjunctions link two verbal sections to be evaluated in sequence. They differ in rank and treatment of dyadic case.

Name Form Monad Dyad Rank
Atop u@v
Essays tacit 3.png
Essays tacit 4.png
mv lv rv
At u@:v _ _ _
Compose u&v
Essays tacit 5.png
mv mv mv
Appose u&:v _ _ _

Dual

The following produce a three part sequence of verbal sections with the last one being the obverse of the first.

Under piecewise u&.v
Essays tacit 6.png
Essays tacit 7.png
mv mv mv
Under in toto u&.:v _ _ _

Train of Verbs

In verbal trains monadic or dyadic input is optionally branched and/or separated (dyadic into two monadic) and applied dyadically or monadically to the verbs sequentially or by joining the results of intermediate evaluation into a dyadic input.

Name Form Monad Dyad Rank
Hook    (u v)
Essays tacit 8.png
Essays tacit 9.png
_ _ _
Fork  (w u v)
Essays tacit 10.png
Essays tacit 11.png
_ _ _
Capped Fork ([: u v)
Essays tacit 3.png
Essays tacit 4.png
_ _ _

Dyadic fork is the most general case, whereas other cases are obtained by removal of certain branches or splits.

In [1] the effect of hook was achieved by the Withe conjunction, except its rank was mv lu mv.

Higher order operations

In general, the foundation of J language, the parts of speech -- adverbs, conjunctions and gerunds -- do the job of linking the sections of the pipeline to produce various types of pathways.

Selection

This group of conjunctions control the manner in which verbal sections are selected and applied.

Power conjunction u^:n (u^:v) specifies whether (n=0 or not), how many times (|n) or using the obverse (n<0) to apply the verbal section, based on the value of noun n (result of verb v). (See Dyadic Bond conjunction.)

Power u^:n
Essays tacit 12.png
Essays tacit 13.png
_ _ _

Agenda conjunction m@.n (m@.v) selects a verb of gerund m, based on the value of n (result of v). If n (result of v) is boxed it creates a parenthesized train.

Evoke Gerund Append m`:0 creates a train with Append (,) between verbs of m.

Evoke Gerund Train m`:6 creates a train of verbs of m.

Apply foreign x 128!:2 y applies string in x to y.

Conjunction Adverse u::v evaluates v is u fails.

Structural

Structural modifyers control how data is broken into pieces and sent through the verbal sections.

Rank conjunction f"n modifies the throughput capacity of a verbal section.

Monadic adverb Insert u/ y (m/ y) or Evoke Gerund Insert m`:3 y break the input into items (cells of rank _1) and insert the verb u (cyclically verbs of m).

Dyadic adverb Table x u/ y applies u to each cell of x and y in toto.

Monadic conjunction Determinant u . v applies u and v recursively on minors of the input.

Dyadic conjunction Dot Product u . v applies as u@(v"(1+lv,_)).

Level At conjunction u L: n applies the verb u at the levels specified by n.

Spread conjunction u S: n produces the list resulting from applying u to the argument(s) at levels n.

Note: other higher order operations may result in piecewise passage of input, for example &.> and @ as opposed to @: control how data is broken for further processing. Also, combination of selection and structural verbs applied to to the same input sent along parallel paths and then collected can explicitly accomplish a similar result of structural dataflow.

Partitions

Partitions are related to structural modifiers. They apply verbs to intra-cell possibly overlapping parts of the input other than left/right argument or rank cells.

Form Monad Dyad Rank
u\ m\ Prefix Infix _ 0 _
u\. m\. Suffix Outfix _ 0 _
u/. m/. Oblique Key Classify _ _ _

Cut conjunctions u;.n (m;.n) define another family of partitioning modifiers.

Form Monad Dyad Rank
u;. 0 Reverse each axis Sub-block _ 2 _
u;. 1 By initial preserving fret By frets in x _ 1 _
u;._1 By initial fret _ 1 _
u;. 2 By final preserving fret _ 1 _
u;._2 By final fret _ 1 _
u;. 3 Max blocks By blocks _ 2 _
u;._3 By complete blocks _ 2 _

Specialization

Monadic Bond conjunction u&n and m&v fixes the noun to the dyadic verb.

Dyadic Bond conjunction x u&n y and x m&v y in addition uses x as Power conjunction n argument.

Inverse Conjunction u:.v specifies the obverse v for verb u.

Fit conjunction modifies certain verbs in ways prescribed in their definitions.

Mathematical

Taylor u t., Weighted Taylor u t:, Taylor Approximation u T. n

Even u..v, Odd u.:v

Derivative conjunction u d. n, u D. n.

Secant Slope u D: n

Hypergeometric m H. n

Related Areas

Argument Aliases

Argument aliases make tacit expressions look as familiar mathematical formulas.

'`X Y'=: [`]
sum=: X + Y

Tacit Valued Explicit Definitions

See Tacit Valued Explicit Definitions

Non-tacit Expressions

Tacit Definition

Explicit Definition

See Also

  • [1] Iverson, K.E., A Dictionary of APL, ACM APL Quote-Quad, Volume 18, Number 1, September, 1987.
  • [2] Roger K. W. Hui, Kenneth E. Iverson, Eugene E. McDonnell: Tacit Definition. APL91, Conference on APL 1991: 202-211
  • [3] E. E. McDonnell , K. E. Iverson, Phrasal forms, ACM SIGAPL APL Quote Quad, v.19 n.4, p.197-199, Aug. 1989
  • WikiPedia:Functional_programming, Wikipedia
  • Parts of speech, J Dictionary
  • Trains, ibid
  • Help/Primer/095_Explicit-to-tacit
  • Help/Primer/094_Tacit_definition

Discussion

Essays/Tacit Expressions/Comments /Comments