Branch

From APL Wiki
Revision as of 06:46, 27 July 2020 by Andrii Makukha (talk | contribs) (Created page with "{{Built-in|Branch|→}} is a primitive monadic function which provides a way to control execution flow in an APL programs. It is equivalent to GOTO...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Branch () is a primitive monadic function which provides a way to control execution flow in an APL programs. It is equivalent to GOTO statement in other programming languages.

It appeared in early versions of APL. In some APL dialects it was superseded by the more modern control structures.

Examples

Branch function can be used to implement structured programming constructs without the use of special keywords:[1]

      ⍝ If-Then-Else construct
      →(~B)/Else
       S1
       →End
      Else:
       S2
      End:
      ⍝ Select construct
      →(Case1, Case2, Case3, Case4)[i]
      Case1: S1
       →Next
      Case2: S2
       →Next
      Case3: S3
       →Next
      Case4: S4
      Next:
      ⍝ While-Do construct
      While:→(~B)/Done
       S1
       →While
      Done:
      ⍝ Repeat-Until construct
      Repeat:S2
       →(~B)/Repeat

External links

Tutorials

Documentation

References