4,494
edits
(→Trains) |
|||
(10 intermediate revisions by 2 users not shown) | |||
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. | 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 functions (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> | {| | ||
|<source lang=apl> (g h) ⍵</source>|| {{←→}} ||<source lang=apl>g ( h ⍵)</source> | |||
⍺ (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> | {| | ||
|<source lang=apl> (f g h) ⍵</source>|| {{←→}} ||<source lang=apl>( f ⍵) g ( h ⍵)</source> | |||
⍺ (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> | |||
|} | |||
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> | ||
Line 58: | Line 60: | ||
=== Plus and minus === | === Plus and minus === | ||
<source lang=apl> | <source lang=apl> | ||
(+,-)2 | (+,-) 2 ⍝ ±2 | ||
2 ¯2 | 2 ¯2 | ||
5 (+,-) 2 ⍝ 5±2 | |||
7 3 | |||
</source> | </source> | ||
Line 122: | Line 121: | ||
== External links == | == External links == | ||
== Tutorials == | == Tutorials == | ||
* [https://chat.stackexchange.com/rooms/52405/conversation/lesson-23-transcribing-to-and-reading-trains Transcribing to and reading trains] | * Dyalog: [http://help.dyalog.com/16.0/Content/RelNotes14.0/Function%20Trains.htm version 14.0 release notes] | ||
* [https://www.youtube.com/watch?v=kt4lMZbn-so How to read trains in Dyalog APL code] (video) | * APL Cultivation: [https://chat.stackexchange.com/rooms/52405/conversation/lesson-23-transcribing-to-and-reading-trains Transcribing to and reading trains] | ||
* [https://www.youtube.com/watch?v=A2LqqBosvY0 Function trains in APL] (video) | * APLtrainer: [https://www.youtube.com/watch?v=kt4lMZbn-so How to read trains in Dyalog APL code] (video) | ||
== Documentation | * APLtrainer: [https://www.youtube.com/watch?v=A2LqqBosvY0 Function trains in APL] (video) | ||
* Dyalog Webinar: [https://www.youtube.com/watch?v=Enlh5qwwDuY?t=440 Train Spotting in Dyalog APL] (video) | |||
* Dyalog '13: [https://www.youtube.com/watch?v=7-93GzDqC08 Train Spotting in Version 14.0] (video) | |||
== Documentation == | |||
* [http://help.dyalog.com/16.0/Content/RelNotes14.0/Function%20Trains.htm Announcement] | * [http://help.dyalog.com/16.0/Content/RelNotes14.0/Function%20Trains.htm Announcement] | ||
* [http://help.dyalog.com/latest/Content/Language/Introduction/Trains.htm Dyalog] | * [http://help.dyalog.com/latest/Content/Language/Introduction/Trains.htm Dyalog] | ||
==References== | ==References== | ||
<references/> | <references/> | ||
{{APL syntax}} | {{APL syntax}} |