From J Wiki
Jump to: navigation, search

Back to: Vocabulary

Gerunds and Atomic Representation


A gerund is a noun that represents one or more verbs.

You use a gerund when you want to

  • Provide a verb as an argument to another verb
    because only nouns can be arguments to verbs
  • Provide more than two verb operands to an adverb, or more than three verb operands to a conjunction

You create a gerund with the Tie conjunction (`).


One of the variants of the Amend adverb (}) uses three verb operands, which are passed in as a single gerund:

   ]a =. 'abracadabra'
   'x' [`([: I. 'a' = ])`]} a 
   ('x' [ a) ('x' ([: I. 'a' = ]) a)} ('x' ] a)   NB. Execution of the gerund form is equivalent to this


1. A gerund is a list of boxes or a single atomic box. Each box in a gerund describes one verb.

2. Because of its clever definition, (u`v) can be used to create gerunds containing any number of verbs. Each of u/v that is a verb is converted to a single-box gerund form, while each that is a noun is left unchanged. Then the possibly-modified operands are joined into a single list. Thus, when a sequence such as


is executed, the first execution is


producing a 2-atom list of boxes, followed by

   ((,'+');,'-') ` *

which leaves unchanged the left argument (the previously-created gerund, which is a noun) and appends the gerund form of the right argument.

3. To create the gerund form of a single verb, use u`'' or ''`v which will produce a single gerund as a one-atom list.

Exactly What Is A Gerund?

  • A gerund is not a special datatype.
  • A gerund is a single box or list of boxes each of which is the atomic representation of a verb.
  • You can create a gerund by giving a verb operand to the Tie conjunction (`)
  • But you can also create a gerund by hand, building up the atomic representation.

So what is a gerund?

A gerund is a box or list of boxes, where each box contains the atomic representation of a verb.

Atomic Representation

A gerund is a special case of atomic representation (AR), which is a way of representing any entity as an atomic boxed noun.

You can create an atomic representation by following the rules below, or you can use 5!:1 to produce the AR of a named entity.

   sum =: +/
|| ||+|||
|| |+-+||

In addition, you can use the Tie conjunction (`) to create the AR of a verb.

AR format

An AR is an atomic box whose contents are

  • a list of characters representing either
    if there is only one character, it may be an atom rather than a list, though the interpreter will always make a list
    • a primitive
    • a name
  • a list of 2 boxes, where
    • the first box contains characters, either
      • a primitive
      • a code indicating how the remaining box is to be interpreted
    • the contents of the second box is interpreted according to the value of the first box, and is either the value of a noun, or a list of ARs

To see the AR of a named entity, execute 5!:1<'entityname'.

How to map trains and compound entities into AR format

To build an AR by hand, write out the sequence of J words that would represent the entity, and then emulate the action of the parser. Whenever the parser would execute a fragment, combine the words of the fragment into a single AR. What you are left with at the end of execution will be the final AR.

Action Example Code to produce AR AR for example
- noun (when an AR is needed, for the final result or for an operand to an adverb or conjunction) 'abc' < (<,'0') , < value of noun < (<,'0') , < 'abc'
- named verb, adverb, or conjunction each If the entity itself is executed, the AR is the AR of its value. If not (i. e. only its name is needed), and the entity was assigned with the name of another entity, the AR is the boxed name of the other entity.

Example: in u@v, @ is executed, but u and v are not.

0 Monad i. 5 None. These lines are executed to produce noun results which are passed into subsequent executions
1 Monad *: i. 5
2 Dyad 2 + 3
7 assignment name =. None. Ignored.
8 () (i. 5) None. Parsing continues inside the parentheses
3 adverb execution +/ < AR for value of adverb , < , AR for verb/noun < (<,'/') , < , < , '+'
4 conjunction execution < AR for value of conjunction , < AR for left operand , AR for right operand ')
5 fork ({. - {:) < (<,'3') , < AR for left tine , AR for middle tine , AR for right tine < (<,'3') , < (< '{.') , (< , '-') , (< '{:')
6 hook (% {.) < (<,'2') , < AR for left tine , AR for right tine < (<,'2') , < (< , '%') , (< '{.')
6 (adv adv), (conj verb/noun), or (verb/noun conj) (& 2) < (<,'4') , < AR for left tine , AR for right tine < (<,'4') , < (< , '&') , (< ((<,'0') , < 2)