Tacit programming

From APL Wiki
Revision as of 10:45, 9 January 2020 by RichPark (talk | contribs) (Created page with "Tacit functions apply to implicit arguments following a small set of rules. This is in contrast to the explicit use of arguments in dfns (<source inline lang=apl>⍺ ⍵</sour...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Tacit functions apply to implicit arguments following a small set of rules. This is in contrast to the explicit use of arguments in dfns (⍺ ⍵) and Tradfns (which have named arguments). Known dialects which implement trains are Dyalog APL, dzaima/apl, ngn/apl and NARS2000.

Primitives

All primitive functions are tacit. Some APLs allow primitive functions to be named.

      plus ← +
      times ← ×
      6 times 3 plus 5
48

Trains

A train is a series of functions in isolation. An isolated function is either surrounded by parentheses or named. Arguments are processed by the following rules:

A 2-train is an atop:

  (g h) ⍵ ⬄ g (  h ⍵)
⍺ (g h) ⍵ ⬄ g (⍺ h ⍵)

A 3-train is a fork:

  (f g h) ⍵ ⬄ (  f ⍵) g (  h ⍵)
⍺ (f g h) ⍵ ⬄ (⍺ f ⍵) g (⍺ h ⍵)

The left tine of a fork (but not an atop) can be an array:

  (A g h) ⍵ ⬄ A g (  h ⍵)
⍺ (A g h) ⍵ ⬄ A g (⍺ h ⍵)

Expressing algorithms

One of the major benefits of tacit programming is the ability to convey a short, well-defined idea as an isolated expression (example).

Template:APL Language