4,505
edits
m (Categories) |
|||
Line 65: | Line 65: | ||
</source> | </source> | ||
=== Each left and each right === | |||
A common problem is pairing up each [[element]] of one [[argument]] with all the elements of another argument. Because of scalar extension, [[enclose|making one argument a scalar]] accomplishes this: | |||
<source lang=apl> | |||
1 2 3,¨⊂100 200 | |||
┌─────────┬─────────┬─────────┐ | |||
│1 100 200│2 100 200│3 100 200│ | |||
└─────────┴─────────┴─────────┘ | |||
(⊂1 2 3),¨100 200 | |||
┌─────────┬─────────┐ | |||
│1 2 3 100│1 2 3 200│ | |||
└─────────┴─────────┘ | |||
</source> | |||
For [[scalar function]]s, explicit use of the [[Each]] operator is unnecessary: | |||
<source lang=apl> | |||
1 2 3+⊂100 200 | |||
┌───────┬───────┬───────┐ | |||
│101 201│102 202│103 203│ | |||
└───────┴───────┴───────┘ | |||
(⊂1 2 3)+100 200 | |||
┌───────────┬───────────┐ | |||
│101 102 103│201 202 203│ | |||
└───────────┴───────────┘ | |||
</source> | |||
[[Bind]]ing one argument to the function also works, but this always requires the Each operator: | |||
<source lang=apl> | |||
1 2 3∘,¨100 200 | |||
┌─────────┬─────────┐ | |||
│1 2 3 100│1 2 3 200│ | |||
└─────────┴─────────┘ | |||
(,∘100 200)¨1 2 3 | |||
┌─────────┬─────────┬─────────┐ | |||
│1 100 200│2 100 200│3 100 200│ | |||
└─────────┴─────────┴─────────┘ | |||
</source> | |||
== See also == | |||
* [[Rank (operator)]] | |||
{{APL features}}[[Category:Function characteristics]][[Category:Conformability]] | {{APL features}}[[Category:Function characteristics]][[Category:Conformability]] |