APL Wiki logo: Difference between revisions

Jump to navigation Jump to search
15 bytes added ,  01:15, 3 November 2019
Miraheze>Adám Brudzewsky
Miraheze>Adám Brudzewsky
Line 63: Line 63:


</source>
</source>
That didn't work! This is because APL dispenses with traditional mathematics' confusing and inconsistent precedence order<ref>K.E. Iverson, [https://www.jsoftware.com/papers/EvalOrder.htm Conventions Governing Order of Evaluation] (Appendix A of Elementary Functions: An Algorithmic Treatment). Science Research Associates, 1966</ref>, replacing it with a simple right-to-left rule:
That didn't work! This is because APL dispenses with traditional mathematics' confusing and inconsistent precedence order<ref>[[Ken Iverson|K.E. Iverson]], Appendix A: [https://www.jsoftware.com/papers/EvalOrder.htm Conventions Governing Order of Evaluation], Elementary Functions: An Algorithmic Treatment). Science Research Associates, 1966</ref>, replacing it with a simple right-to-left rule:
<source lang=apl>
<source lang=apl>
       (⍳5)!4
       (⍳5)!4
1 4 6 4 1
1 4 6 4 1
</source>
</source>
== Swapping arguments ==
== Swapping arguments ==
If the arguments of <source lang=apl inline>!</source> were swapped, we didn't need that parenthesis. Enter the [[operator]] (higher-order function) [[swap]] (<source lang=apl inline>⍨</source>) which takes a [[dyadic]] function on its left and creates a new [[derived function]] which is identical to the original, but has swapped arguments:
If the arguments of <source lang=apl inline>!</source> were swapped, we didn't need that parenthesis. Enter the [[operator]] (higher-order function) [[swap]] (<source lang=apl inline>⍨</source>) which takes a [[dyadic]] function on its left and creates a new [[derived function]] which is identical to the original, but has swapped arguments:

Navigation menu