1
edit
mNo edit summary |
m (Fix code) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 21: | Line 21: | ||
Dot ← +.× | Dot ← +.× | ||
3 1 4 | 3 1 4 Dot 2 7 1 | ||
17 | 17 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Derived operators == | == Derived operators == | ||
A dyadic operator with its right operand forms a tacit monadic operator: | A dyadic operator with its right operand forms a tacit monadic operator: | ||
Line 37: | Line 38: | ||
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. | ||
These rules are used for 3-trains: | These rules are used for 3-trains, called [[fork]]s: | ||
{| | {| | ||
|<syntaxhighlight lang=apl> (f g h) ⍵</syntaxhighlight>|| {{←→}} ||<syntaxhighlight lang=apl>( f ⍵) g ( h ⍵)</syntaxhighlight> | |<syntaxhighlight lang=apl> (f g h) ⍵</syntaxhighlight>|| {{←→}} ||<syntaxhighlight lang=apl>( f ⍵) g ( h ⍵)</syntaxhighlight> | ||
Line 50: | Line 51: | ||
|} | |} | ||
In APL (but not [[J]]), these rules are used for 2-trains: | In APL (but not [[J]]), these rules are used for 2-trains, called [[atop]]s: | ||
{| | {| | ||
|<syntaxhighlight lang=apl> (g h) ⍵</syntaxhighlight>|| {{←→}} ||<syntaxhighlight lang=apl>g ( h ⍵)</syntaxhighlight> | |<syntaxhighlight lang=apl> (g h) ⍵</syntaxhighlight>|| {{←→}} ||<syntaxhighlight lang=apl>g ( h ⍵)</syntaxhighlight> | ||
Line 66: | Line 67: | ||
|<syntaxhighlight lang=apl>(⊢ g f) ⍵</syntaxhighlight>|| {{←→}} ||<syntaxhighlight lang=apl>g∘f⍨ ⍵</syntaxhighlight> | |<syntaxhighlight lang=apl>(⊢ g f) ⍵</syntaxhighlight>|| {{←→}} ||<syntaxhighlight lang=apl>g∘f⍨ ⍵</syntaxhighlight> | ||
|} | |} | ||
== Debugging == | == Debugging == | ||
Line 197: | Line 197: | ||
666 ⍝ the sum of the squares of the primes up to 17 | 666 ⍝ the sum of the squares of the primes up to 17 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Note that <syntaxhighlight lang=apl inline>(( | Note that <syntaxhighlight lang=apl inline>((⊢~∘.×⍨)1↓⍳)</syntaxhighlight> is a train computing primes up to the given input. | ||
A more satisfying variation of the accursed train is the following. | A more satisfying variation of the accursed train is the following. |
edit