In APL syntax, a niladic function is a special type of function that takes no arguments and is evaluated immediately when it is encountered in a statement. It cannot be used as an operand because this evaluation happens before operator binding, or any other evaluation step such as stranding. For this reason operators are always defined to take non-niladic operands. Niladic is considered one of three possible function valences along with monadic and dyadic.
∇ res←set_a a ← 'a' res ← 1 ∇
After defining such a function, it can be evaluated simply by writing its name, with no need to indicate any arguments. A niladic function is the only possible named entity with this behaviour: for any other kind of value, writing the name alone in a statement will simply return that value, but for a niladic function it evaluates the function and returns the result.
a VALUE ERROR: Undefined name: a a ∧ set_a 1 a a
|APL syntax |
|General||Comparison with traditional mathematics ∙ Precedence ∙ Tacit programming|
|Array||Numeric literal ∙ String ∙ Strand notation ∙ Object literal ∙ Array notation|
|Function||Argument ∙ Function valence ∙ Derived function ∙ Derived operator ∙ Niladic function ∙ Monadic function ∙ Dyadic function ∙ Ambivalent function ∙ Tradfn ∙ Dfn ∙ Function train|
|Operator||Operand ∙ Operator valence ∙ Tradop ∙ Dop ∙ Derived operator|
|Assignment||Multiple ∙ Indexed ∙ Selective ∙ Modified|
|Other||Function axis ∙ Branching ∙ System command ∙ User command ∙ Keyword ∙ Dot notation|