Sample 21. Closure

>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help Dictionary

21. Closure
Just as`b imfam cm` produces the immediate family of`b`,`` so does the phrase`cm imfam cm` produce the immediate families of each of the rows of`cm`.`` We will, however, use a new sparser connection matrix that will be more instructive, and will use powers of`imfam` to produce families of further generations, including an infinite power to give the closure of the connection matrix; that is, the connection matrix for all points reachable by a path of any length:

       cm=: (i. =/ <:@i.) 8
       <"2 cm imfam^:0 1 2 _ cm
    +---------------+---------------+---------------+---------------+
    |0 1 0 0 0 0 0 0|0 1 1 0 0 0 0 0|0 1 1 1 0 0 0 0|0 1 1 1 1 1 1 1|
    |0 0 1 0 0 0 0 0|0 0 1 1 0 0 0 0|0 0 1 1 1 0 0 0|0 0 1 1 1 1 1 1|
    |0 0 0 1 0 0 0 0|0 0 0 1 1 0 0 0|0 0 0 1 1 1 0 0|0 0 0 1 1 1 1 1|
    |0 0 0 0 1 0 0 0|0 0 0 0 1 1 0 0|0 0 0 0 1 1 1 0|0 0 0 0 1 1 1 1|
    |0 0 0 0 0 1 0 0|0 0 0 0 0 1 1 0|0 0 0 0 0 1 1 1|0 0 0 0 0 1 1 1|
    |0 0 0 0 0 0 1 0|0 0 0 0 0 0 1 1|0 0 0 0 0 0 1 1|0 0 0 0 0 0 1 1|
    |0 0 0 0 0 0 0 1|0 0 0 0 0 0 0 1|0 0 0 0 0 0 0 1|0 0 0 0 0 0 0 1|
    |0 0 0 0 0 0 0 0|0 0 0 0 0 0 0 0|0 0 0 0 0 0 0 0|0 0 0 0 0 0 0 0|
    +---------------+---------------+---------------+---------------+

The closure of`cm` can therefore be expressed as`cm imfam^:_ cm`,`` and a monadic closure function can be defined as follows:

       (closure=: imfam^:_ ~) cm
    0 1 1 1 1 1 1 1
    0 0 1 1 1 1 1 1
    0 0 0 1 1 1 1 1
    0 0 0 0 1 1 1 1
    0 0 0 0 0 1 1 1
    0 0 0 0 0 0 1 1
    0 0 0 0 0 0 0 1
    0 0 0 0 0 0 0 0

The complete definition of the closure function may now be displayed as follows:

       closure f.
    ([ +. +./ .*.)^:_~

>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help Dictionary