Tacit programming: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
(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...")
 
No edit summary
Line 1: Line 1:
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>⍺ ⍵</source>) and Tradfns (which have named arguments). Known dialects which implement trains are Dyalog APL, dzaima/apl, ngn/apl and NARS2000.
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>⍺ ⍵</source>) and [[tradfns]] (which have named arguments). Known dialects which implement trains are Dyalog APL, dzaima/apl, ngn/apl and NARS2000.


== Primitives ==
== Primitives ==

Revision as of 10:50, 9 January 2020

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