Scalar extension: Difference between revisions

Jump to navigation Jump to search
641 bytes added ,  09:54, 8 July 2021
Line 42: Line 42:
       1 2 3 4 * 2
       1 2 3 4 * 2
1 4 9 16
1 4 9 16
    100,¨1 2 3 4
┌─────┬─────┬─────┬─────┐
│100 1│100 2│100 3│100 4│
└─────┴─────┴─────┴─────┘
</source>
</source>




[[Replicate]] and [[Expand]] extend a scalar left argument to apply to each element of the right argument:
[[Replicate]] and [[Partitioned Enclose]] (and also [[Partition]], but this is less useful, as it is equivalent to <source lang=apl inline>,⊂</source> or  <source lang=apl inline>{0⍴⊂0⍴⍵}</source>) extend a scalar left argument to apply to each column of the right argument:
<source lang=apl>
<source lang=apl>
       2/'abc'
       2/'abc'
aabbcc
aabbcc
      2⊂'abc'
┌┬─┬┬─┬┬─┐
││a││b││c│
└┴─┴┴─┴┴─┘
</source>
</source>
[[Decode]] uses extends a single radix left argument to apply to all digit values in the right argument:
<source lang=apl>
      2⊥1 0 1
5
</source>
[[APL2]] and [[Dyalog APL]] use a variant of singleton extension when the selected axis of the right argument has length one: each element along that axis is reused for every element of the left argument.
[[APL2]] and [[Dyalog APL]] use a variant of singleton extension when the selected axis of the right argument has length one: each element along that axis is reused for every element of the left argument.
<source lang=apl>
<source lang=apl>

Navigation menu