Tacit programming: Difference between revisions

Jump to navigation Jump to search
664 bytes added ,  15:40, 9 January 2020
Line 32: Line 32:


== Trains ==
== 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 train is a series of functions in isolation. An isolated function is either surrounded by parentheses or named. Below, <source lang=apl inline>⍺</source> and <source lang=apl inline>⍵</source> refer to the arguments of the train. <source lang=apl inline>f</source>, <source lang=apl inline>g</source>, and <source lang=apl inline>h</source> are function (which themselves can be tacit or not), and <source lang=apl inline>A</source> is an array. The arguments are processed by the following rules:


A 2-train is an ''atop'':
A 2-train is an ''atop'':
<source lang=apl>
{|
  (g h) ⍵ g (  h ⍵)
|<source lang=apl> (g h) ⍵</source>|| {{←→}} ||<source lang=apl>g (  h ⍵)</source>
⍺ (g h) ⍵ g (⍺ h ⍵)
|-
</source>
|<source lang=apl>⍺ (g h) ⍵</source>|| {{←→}} ||<source lang=apl>g (⍺ h ⍵)</source>
 
|}
A 3-train is a ''fork'':
A 3-train is a ''fork'':
<source lang=apl>
{|
  (f g h) ⍵ (  f ⍵) g (  h ⍵)
|<source lang=apl> (f g h) ⍵</source>|| {{←→}} ||<source lang=apl>(  f ⍵) g (  h ⍵)</source>
⍺ (f g h) ⍵ (⍺ f ⍵) g (⍺ h ⍵)
|-
</source>
|<source lang=apl>⍺ (f g h) ⍵</source>|| {{←→}} ||<source lang=apl>(⍺ f ⍵) g (⍺ h ⍵)</source>
|}
The ''left tine'' of a fork can be an array:
{|
|<source lang=apl>  (A g h)</source>|| {{←→}} ||<source lang=apl>A g (  h ⍵)</source>
|-
|<source lang=apl>⍺ (A g h) ⍵</source>|| {{←→}} ||<source lang=apl>A g (⍺ h ⍵)</source>
|}


The ''left tine'' of a fork can be an array:
<source lang=apl>
  (A g h) ⍵ ⬄ A g (  h ⍵)
⍺ (A g h) ⍵ ⬄ A g (⍺ h ⍵)
</source>
Only [[dzaima/APL]] allows <source lang=apl inline>(A h)</source>, which it treats as <source lang=apl inline>A∘h</source>.<ref>dzaima/APL: [https://github.com/dzaima/APL/blob/ceea05e25687988ed0980a4abf4b9249b736543f/docs/differences.txt#L19 Differences from Dyalog APL]. Retrieved 09 Jan 2020.</ref>
Only [[dzaima/APL]] allows <source lang=apl inline>(A h)</source>, which it treats as <source lang=apl inline>A∘h</source>.<ref>dzaima/APL: [https://github.com/dzaima/APL/blob/ceea05e25687988ed0980a4abf4b9249b736543f/docs/differences.txt#L19 Differences from Dyalog APL]. Retrieved 09 Jan 2020.</ref>


Navigation menu