⍣) is a primitive dyadic operator that performs bounded looping, unbounded looping, and function inverses in NARS2000, Dyalog APL, and related implementations like ngn/apl, dzaima/APL, and Extended Dyalog APL.
A call to Power is of the form
Xis an optional argument.
fis a function. If
Xis given, then it is bound to
X f⍣g Yis equivalent to
gcan be an array or a function.
Power repeatedly applies
Y based on the type of operand
- Function: Must be dyadic and must return a boolean singleton. The previous iteration value is provided as left argument to
f, and the current iteration value is given as right argument.
fis repeatedly applied until this function returns 1.
- Integer: Applies
gis negative, then the inverse of
f(if available) is applied.
- Integer Array: In Extended Dyalog APL,
gcan be an integer array. Each integer
gwill be replaced by
Some basic examples:
1 (+⍣3) 5 ⍝ Fixed number of iterations 8 (2∘×⍣3) 5 ⍝ No X given 40 1 +∘÷⍣= 1 ⍝ iterate till fixed point 1.618033989
A well-known use for Power is iterating until a fixed point is reached.
(∨.∧⍨∨⊢)⍣≡3 3⍴0 0 1 1 0 1 1 0 1 ⍝ Transitive closure of an adjacency matrix 1 0 1 1 0 1 1 0 1
Power is also used to access function inverses.
2(⊥⍣¯1)5 1 0 1