Take: Difference between revisions

Jump to navigation Jump to search
40 bytes added ,  12:21, 17 October 2019
m
→‎Examples: class=apl
Miraheze>Marshall
(Examples)
Miraheze>Marshall
m (→‎Examples: class=apl)
Line 14: Line 14:


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.
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.
<pre>
<pre class=apl>
       8 ↑ 5 4 3 2 1
       8 ↑ 5 4 3 2 1
5 4 3 2 1 0 0 0
5 4 3 2 1 0 0 0
Line 23: Line 23:


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:
<pre>
<pre class=apl>
       ¯2 3↑⍳4 5
       ¯2 3↑⍳4 5
┌───┬───┬───┐
┌───┬───┬───┐
Line 34: Line 34:


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.
<pre>
<pre class=apl>
       ¯2↑⍳4 5
       ¯2↑⍳4 5
┌───┬───┬───┬───┬───┐
┌───┬───┬───┬───┬───┐
Line 45: Line 45:


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.
<pre>
<pre class=apl>
       ¯2↑[2]⍳4 5
       ¯2↑[2]⍳4 5
┌───┬───┐
┌───┬───┐
Anonymous user

Navigation menu