Essays/Trains

From J Wiki
Jump to: navigation, search

The origins and evolution of trains.


References

Origins

For years, Ken had struggled to find a way to write f+g as in calculus, from the "scalar operators" in Operators and Functions [5, section 4], through the "til" operator in Practical Uses of a Model of APL [6] and Rationalized APL [7, p. 18], and finally forks. Forks are defined as follows:

   (f g h) y ↔ (f y) g (h y)
 x (f g h) y ↔ (x f y) g (x h y)

Moreover, (f g p q r) ↔ (f g (p q r)) . Thus to write f+g as in calculus, one writes f+g in J.

            -- Remembering Ken Iverson

Proof of Completeness

Suppose s is a sentence on nouns x. and y. that results in a noun, and s makes no use of x. or y. as arguments to an adverb or conjunction. We define an adverb T which translates s into an equivalent tacit verb. Without loss of generality, assume that s contains no copulae; for if it does, d=.rhs (say), recursively replace instances of d by (rhs) .

If s contains no verbs, s T is:

[ if s is x.
] if s is y.
a"_ if s is a noun a which is neither x. nor y. (a"_ is a constant verb with value a and infinite rank)

Otherwise, let f be the root verb in s ; so s is either f q or p f q where p and q are sentences shorter than s and are (by induction) translatable by T . Thus s T is f@(q T) if s is f q and s T is (p T)f(q T) if s is p f q .

            -- Tacit Definition

Example

We translate the sentence (^x) + (x^2) - (y^2) using the method described in the proof (using x and y instead of x. and y. which prevailed in 1991).

'(^x) + (x^2) - (y^2)' T
('^x' T) + ('(x^2) - (y^2)' T)                        + is the root verb
(^@('x' T)) + (('x^2' T) - ('y^2' T))                 ^ and - are the root verbs
(^@[) + ((('x' T)^('2' T)) - (('y' T)^('2' T)))       s is x; ^ are the root verbs
(^@[) + ((([^2"_) - (]^2"_)))                         s0 is x; s1 is y; constants

In this case terser tacit expressions are possible: ^@[ + *:@[ - *:@] or, even better, ^@[ + -&*:

See also



Contributed by Roger Hui.