>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Voc  !:  Help  Dictionary

Self Reference $:  _ _ _  

$: denotes the longest verb that contains it.                                                                                                    

Example 1:
   1:`(] * $:@<:)@.* 5
120
In the foregoing expression, the agenda (@.) chooses the verb ] * $:@<: as long as the argument (reduced by one each time by the application of the decrement) remains non-zero. When the argument becomes zero, the result of the right argument of @. is zero, and the constant function 1: is chosen.

If $:@ were omitted from the expression, it would execute once only as follows:
   1:`(] * <:)@.* 5
20
The inclusion of self-reference ensures that the entire function is re-executed after decrementing the argument.

Example 2: In quicksort, a “pivot” is chosen at random from the list to be sorted. The overall result is the sorted result of the part less than the pivot, catenated to the part equal to the pivot, catenated to the sorted result of the part greater than the pivot.

   quicksort=: (($:@(<#[) , (=#[) , $:@(>#[)) ({~ ?@#)) ^: (1<#)

   ] v=: 20 ?.@$ 13
10 3 3 6 11 11 4 0 10 2 5 6 2 0 1 3 12 10 11 5
   quicksort v
0 0 1 2 2 3 3 3 4 5 5 6 6 10 10 10 11 11 11 12


>>  <<  Usr  Pri  JfC  LJ  Phr  Dic  Voc  !:  Help  Dictionary