rslt ← (func ##.while cond) argt            ⍝ Conditional function power.

Left  operand  [func]  is  applied  cumulatively  to argument [argt] while right
operand  [cond]  returns "true". Notice that, in common with the :While ··· :End
control structure, if (cond argt) is initially false, [func] is applied 0 times.
Compare this with the →until← operator.

Examples:

      ,∘'.' while (80>⍴) 'Note'             ⍝ Extend while less than 80 wide.
Note............................................................................

      ↓ while {1<⍴⍴⍵} 2 2 2 2⍴⍳16           ⍝ Split while high rank.
┌─────────────────────┬────────────────────────────┐
│┌─────────┬─────────┐│┌────────────┬─────────────┐│
││┌───┬───┐│┌───┬───┐│││┌────┬─────┐│┌─────┬─────┐││
│││1 2│3 4│││5 6│7 8│││││9 10│11 12│││13 14│15 16│││
││└───┴───┘│└───┴───┘│││└────┴─────┘│└─────┴─────┘││
│└─────────┴─────────┘│└────────────┴─────────────┘│
└─────────────────────┴────────────────────────────┘

      {⍵+1} while {0} 0                     ⍝ {⍵+1} applied 0 times.
0

See also: cond until limit pow traj acc

Back to: contents

Back to: Workspaces