Elements of J Grammar 8 Feb 1994. NB. Execution is RIGHT TO LEFT eg. 3-2-1 --> 3-(2-1) --> 2 Adverb: /, \ etc. modifies a verb eg. the / modifies + to make a new verb +/ in +/ 1 2 3 --> 1+2+3 --> 6 Conjunction: &, @ eg. the bond ^&2 of verb ^ and noun 2 form a verb ^&2 in (^&2) 4 --> 4^2 --> 16 eg. the conjunction *:@! of verbs *: and ! in (*:@!)3 --> *:6 --> 36 Copula: =. and =: is, assignment =. local =: global Explicit Definition of a function or program: (see tacit definition) NB. all functions have either one (right) or two (left & right) parameters. MonadicCase : DyadicCase eg. roots =. '2 %: y.' : 'x. %: y.' roots 9 --> 3 3 roots 8 --> 2 may have tables or boxed lists of n sentences to left and right of : sequence control is by suite $. initially set to 0 1 2 3 ... n-1 changing $. changes the sequence of evaluation Fork: an isolated sequence of 3 verbs making a new verb (a fork is also a verb train) (a) monadic (f g h) y == (f y) g (h y) eg. (+/ % #) 1 2 3 4 --> 2.5 (b) dyadic x (f g h) y == (x f y) g (x h y) eg. 12(+*-)10 --> (12+10)*(12-10) --> 44 Gerund: ` (tie) @. agenda, g @. a is like case 2 (+`^)@. < 3 --> 2^3 because 2<3 returns 1 which selects ^ --> 8 Hook: (a hook is also a verb train) (a) monadic (g h) y == y g (h y) eg. (+!)3 --> 3+!3 --> 9 (b) dyadic x (g h) y == x g (h y) eg. 4(+!)3 --> 4+!3 --> 10 Names: jack jill etc ProgPara: =. 3030 then ProgPara: cannot be changed Special names: $: self-reference x. left argument y. right argument $. suite, sequence control, see explicit definition : Locales (or modules) eg. F_x for locale F and local name x Tacit Definition of a function or program: (see explicit definition) combinator style eg. mean =. +/ % # NB. the adverb :20 converts a string to a tacit definition if possible. Train: (a) Verb Trains, see also fork & hook a train of more than 3 verbs associates to the right (change with ()s) eg. +-*%^< == +(-*(%^<)) ---fork ------fork --------hook (b) adverb train, associates to left (c) conjunction train, associates to left Verb: an action eg . the + in 1+2 --> 3 Most verbs have monadic and dyadic versions in 3 forms eg. + +. and +: and having related meanings.