APL Wiki logo: Difference between revisions
Jump to navigation
Jump to search
m (26 revisions imported: Migrate from miraheze) |
(LaTeX symbols to commands) |
||
Line 47: | Line 47: | ||
</source> | </source> | ||
Notice how APL uses traditional mathematical symbols in a generalised way. The traditional post-fix (after its argument) symbol <math>!</math> is used with a syntax similar to how you'd normally use <math>+</math> or <math> | Notice how APL uses traditional mathematical symbols in a generalised way. The traditional post-fix (after its argument) symbol <math>!</math> is used with a syntax similar to how you'd normally use <math>+</math> or <math>\times</math>. In fact, all APL functions can be used [[Dyad|infix]], like <math>a-b</math> or [[Monad|prefix]], like <math>-b</math>. | ||
Anyway, how many sets of four could you pick? Obviously, only one; all the items: | Anyway, how many sets of four could you pick? Obviously, only one; all the items: | ||
Line 88: | Line 88: | ||
Notice how we were dealing with integers until now, but then we [[multiply]] by a float (non-integer). In APL, you don't need to worry about numeric data type conversions. All numeric types get automatically promoted and demoted as needed. APL implementations will usually use the most compact internal representation. | Notice how we were dealing with integers until now, but then we [[multiply]] by a float (non-integer). In APL, you don't need to worry about numeric data type conversions. All numeric types get automatically promoted and demoted as needed. APL implementations will usually use the most compact internal representation. | ||
=== Traditional mathematical symbols === | === Traditional mathematical symbols === | ||
Also notice that we use a proper multiplication symbol, <math> | Also notice that we use a proper multiplication symbol, <math>\times</math>, for multiplication. If traditional mathematics has a symbol for a concept APL includes then APL will use that symbol. Another example is <math>\div</math> for [[division]]. | ||
== Tables == | == Tables == | ||
Line 129: | Line 129: | ||
</source> | </source> | ||
== Rounding == | == Rounding == | ||
The last step is to round these numbers down. Traditional mathematics writes ''floor'' as <math> | The last step is to round these numbers down. Traditional mathematics writes ''floor'' as <math>\lfloor x \rfloor</math> but APL is regular, so no function is denoted by two separated symbols. If the function takes a single argument, then the symbol will be on the left, so we write [[floor]] as <source lang=apl inline>⌊x</source>: | ||
<source lang=apl> | <source lang=apl> | ||
⌊∘.+⍨.5×4!⍨⍳5 | ⌊∘.+⍨.5×4!⍨⍳5 |