Index   <<   >>

Don’t know what to call it,
but it’s mighty unlak prose

In a standard APL system a function for an identity matrix of size y might be written as

   ∇ z←im y
[1]  z←(y,y)⍴(y+1)↑1
   ∇

   im 2
1 0
0 1

When many APL interpreters execute such a defined function, it must be parsed at least the first time, and reparsed each succeeding time it is executed.

In J one may create the same function by applying the definition conjunction (:) to the literal list embodying the same definition.

   IM=. 3 : '(y,y)$(1+y){.1'
   IM 2
1 0
0 1

Here $ is reshape and {. is take, and y is the canonical name of the right, or only, argument. A J function may be written, as in APL, consisting of as many lines as necessary.

The phrase 3 : '(y,y)$(1+y){.1' is the function desired, and need not be named. It can be applied directly to an argument (that is, used as a nonce function).

   3 : '(y,y)$(1+y){.1' 3
1 0 0
0 1 0
0 0 1