Take: Difference between revisions
Jump to navigation
Jump to search
(→Documentation: BQN link) |
|||
Line 11: | Line 11: | ||
</source> | </source> | ||
The left argument to length specifies a length, and not an index. It does not depend on [[index origin]]. | The left argument to length specifies a length, and not an index. It does not depend on [[index origin]]. | ||
=== Overtaking === | |||
A length which is larger than the argument length causes [[Fill element|fills]] to be inserted. The alignment remains the same: if two different positive arguments are used to take from an array, the one which is closer to zero gives a [[prefix]] of the other result. If they are both negative, it is a [[suffix]] instead. When Take makes an axis longer, it is said to "overtake" along that axis. | A length which is larger than the argument length causes [[Fill element|fills]] to be inserted. The alignment remains the same: if two different positive arguments are used to take from an array, the one which is closer to zero gives a [[prefix]] of the other result. If they are both negative, it is a [[suffix]] instead. When Take makes an axis longer, it is said to "overtake" along that axis. | ||
<source lang=apl> | <source lang=apl> | ||
Line 20: | Line 20: | ||
</source> | </source> | ||
{{Works in|[[Dyalog APL]], [[ngn/apl]]}} | {{Works in|[[Dyalog APL]], [[ngn/apl]]}} | ||
=== Truncation === | |||
A higher-[[rank]] array can be shortened by using a left argument with one element for each axis: | A higher-[[rank]] array can be shortened by using a left argument with one element for each axis: | ||
<source lang=apl> | <source lang=apl> | ||
Line 31: | Line 31: | ||
</source> | </source> | ||
{{Works in|[[Dyalog APL]], [[dzaima/APL]], [[ngn/apl]]}} | {{Works in|[[Dyalog APL]], [[dzaima/APL]], [[ngn/apl]]}} | ||
=== Leading axes === | |||
In languages with the SHARP APL extension, the left argument can be shortened. This causes leading axes of the right argument to be modified while trailing axes are ignored. | In languages with the SHARP APL extension, the left argument can be shortened. This causes leading axes of the right argument to be modified while trailing axes are ignored. | ||
<source lang=apl> | <source lang=apl> | ||
Line 42: | Line 42: | ||
</source> | </source> | ||
{{Works in|[[Dyalog APL]], [[ngn/apl]]}} | {{Works in|[[Dyalog APL]], [[ngn/apl]]}} | ||
=== Function axis === | |||
An [[Function axis|axis]] may be specified to apply left argument elements to specific axes of the right argument. Here the last axis is specified in order to take two columns of the argument. | An [[Function axis|axis]] may be specified to apply left argument elements to specific axes of the right argument. Here the last axis is specified in order to take two columns of the argument. | ||
<source lang=apl> | <source lang=apl> |