trusted
69
edits
No edit summary |
|||
(3 intermediate revisions by 2 users not shown) | |||
Line 56: | Line 56: | ||
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> See [[Bind]]. | 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> See [[Bind]]. | ||
== Debugging == | |||
In [[Dyalog APL]], analysis of trains is assisted by a [[user command]] <source lang=apl inline>]Boxing on</source>. This is achieved by executing the command <source lang=apl inline>]Boxing on</source> and then entering a train without any parameters. A structure of the train will be displayed. | |||
For example, the "accursed train" from the section below can be analysed like this: | |||
<source lang=apl> | |||
]Boxing on | |||
Was OFF | |||
((+.×⍨⊢~∘.×⍨)1↓⍳) ⍝ the train to be analysed | |||
┌───────────────────────────────┬───────┐ | |||
│┌───────────┬─────────────────┐│┌─┬─┬─┐│ | |||
││┌───────┬─┐│┌─┬─┬───────────┐│││1│↓│⍳││ | |||
│││┌─┬─┬─┐│⍨│││⊢│~│┌───────┬─┐│││└─┴─┴─┘│ | |||
││││+│.│×││ │││ │ ││┌─┬─┬─┐│⍨││││ │ | |||
│││└─┴─┴─┘│ │││ │ │││∘│.│×││ ││││ │ | |||
││└───────┴─┘││ │ ││└─┴─┴─┘│ ││││ │ | |||
││ ││ │ │└───────┴─┘│││ │ | |||
││ │└─┴─┴───────────┘││ │ | |||
│└───────────┴─────────────────┘│ │ | |||
└───────────────────────────────┴───────┘ | |||
</source> | |||
Alternatively, a train can be represented in form of a tree: | |||
<source lang=apl> | |||
]Boxing on -trains=tree | |||
Was ON -trains=box | |||
((+.×⍨⊢~∘.×⍨)1↓⍳) ⍝ the train to be analysed | |||
┌───┴───┐ | |||
┌─┴─┐ ┌─┼─┐ | |||
⍨ ┌─┼─┐ 1 ↓ ⍳ | |||
┌─┘ ⊢ ~ ⍨ | |||
. ┌─┘ | |||
┌┴┐ . | |||
+ × ┌┴┐ | |||
∘ × | |||
</source> | |||
Or fully parenthesised: | |||
<source lang=apl> | |||
]Boxing on -trains=parens | |||
Was OFF -trains=box | |||
((+.×⍨⊢~∘.×⍨)1↓⍳) ⍝ the train to be analysed | |||
(((+.×)⍨)(⊢~((∘.×)⍨)))(1↓⍳) | |||
</source> | |||
== Examples == | == Examples == | ||
Line 155: | Line 198: | ||
== External links == | == External links == | ||
=== Tutorials === | === Tutorials === | ||
* Dyalog: [ | * Dyalog: [https://help.dyalog.com/16.0/Content/RelNotes14.0/Function%20Trains.htm version 14.0 release notes] | ||
* [[APL Cultivation]]: [https://chat.stackexchange.com/rooms/52405/conversation/lesson-23-transcribing-to-and-reading-trains Transcribing to and reading trains] | * [[APL Cultivation]]: [https://chat.stackexchange.com/rooms/52405/conversation/lesson-23-transcribing-to-and-reading-trains Transcribing to and reading trains] | ||
* [[APLtrainer]]: [https://www.youtube.com/watch?v=kt4lMZbn-so How to read trains in Dyalog APL code] (video) | * [[APLtrainer]]: [https://www.youtube.com/watch?v=kt4lMZbn-so How to read trains in Dyalog APL code] (video) | ||
Line 163: | Line 206: | ||
=== Documentation === | === Documentation === | ||
* [ | * [https://help.dyalog.com/16.0/Content/RelNotes14.0/Function%20Trains.htm Announcement] | ||
* [ | * [https://help.dyalog.com/latest/Content/Language/Introduction/Trains.htm Dyalog] | ||
== References == | == References == |