Dfns & Dops


A dfn (dop)1The terms dfn and dop refer to a special type of function (or operator) unique to Dyalog. They were originally named dynamic functions and dynamic operators, later abbreviated to Dfns and Dops or D-Fns and D-Ops, but all these terms have been dropped in favour of the current ones. is an alternative function definition style suitable for defining small to medium sized functions. It bridges the gap between operator expressions: rank←⍴∘⍴ and full "header style" definitions such as:

    ∇ rslt←larg func rarg;local...

In its simplest form, a dfn is an APL expression enclosed in curly braces {}, possibly including the special characters and to represent the left and right arguments of the function respectively. For example:

      {(+/⍵)÷⍴⍵} 1 2 3 4    ⍝ Arithmetic Mean (Average)
      3 {⍵*÷⍺} 64           ⍝ ⍺th root

dfns can be named in the normal fashion:

      mean¨(2 3)(4 5)
 2.5  4.5

dfns can be defined and used in any context where an APL function may be found, in particular: