a2
The \ Function: Expand
Monadic (One-Argument) Form
See Scan later in this chapter under APL Operators.
Dyadic (Two-Argument) Form: Expand A\[I1 B or A\B or A+B
The result of the expand function is argument B expanded as indicated by
argument A. Each 1 in argument A selects an
element from argument B and each
0 in argument A inserts a 0 (or blank for character data) in the result. Argument A
must be a logical scalar or vector having the values 0 or 1. Argument B can be any
scalar, vector, or other array. If argument B is a scalar or vector, argument A must
have the same number of 1's as the number of elements in argument B. If
argument B is an array, argument A must have the same number of 1's as the length
of the argument B coordinate being acted on.
When argument B is an
array, the [I] index entry is used to specify the coordinate
that is acted on. If the index entry is omitted, the last coordinate (columns) is
assumed. If the A+B is used, then the first coordinate is assumed.
The rank of the result is the same as the rank of the B argument:
1. (I :I. 1 0 \ 1 2 3
B4-2 3p1 a 3 4 5 b
B
10230
1. 2 3
1.t s (5
1 2 3
000
4- 5 ci
I. 0 1\C1JB
The first coordinate (rows) is
expanded; a row is inserted be-
tween the first and second row.
1. 10 l\c2:JB
1203 2
The second coordinate (columns) is
1.c 5 0 cs - expanded; a column is inserted
1 0 I \I3 between the second and third columns.
1. 2 3
000
4 s 6
The 4 Function: Grade Up
The $symbol is formed by overstriking the A symbol and the I symbol.
Monadic (One-Argument) Form: Grade Up 4B
The grade up function result is the index values that would select the elements of
argument B in ascending order. That is, the first element of the result is the index
of the smallest element in argument B, the next element is the index of the next
smallest element in argument B, and so on. Argument B must be
a numeric vector.
When two or more elements in the vector have the same numeric value, their posi-
tion in the vector determines their order in the result (the index value of the first
occurrence appears first in the output). The number of elements in the result is the
same as the number of elements in the argument:
The following example shows how the grade up function can be
used to sort a vec-
tor into ascending order:
The grade up function is not the inverse of the grade down function because of the
way equal elements are handled; see The Function: Grade Down for an
example
using the grade up and grade down functions with equal elements.
Note: The result of the 4 function depends on the 010 system variable (see Chap-
ter 5 for information on the 010 system variable).
Dyadic (Two-Argument) Form
There is no dyadic form.
83
Previous Page Next Page