82
The \ Function: Expand
CD
Monadic (One-Argument) Form
See Scan later
in
this
chapter
under
APL
Operators.
Dyadic (Two-Argument) Form: Expand A
\[1]
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
o 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 vector, argument A
must
have
the
same number
of
1's as
the
number
of
elements
in
argument
B.
If argument B
is
a multidimensional 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.
If
argument B
is
a scalar
or
single-element array, it
is
extended
to
a length equal
to
the
number
of
1's
in
argument
A.
If argument B
is
not
a scalar
or
single-element
array,
the
rank
of
the
result
is
the
same
as
the
rank
of
the
B argument.
1.
0
:1.
1
0\1
")
I:'.
3
1
0
")
.:..
3
0
B~"2
3~)1
I")
.,.
...
3
4-
5 6
B
1.
2
3
1+
1:."
.J
6
t
{}
l\[lJB
:L
~~
"y
\
The first coordinate (rows)
is
,:)
()
0
0
expanded; a row
is
inserted be-
4·
5 b
tween
the
first and second row.
l 1
0
1\[2JB
1
")
0
3
'\
The second coordinate (columns)
is
.:..
I.~
c:-
O 6
expanded; a column
is
inserted
.J
1
0
l\.B
between
the
second and third columns.
1
")
It:
••
3
0 0
{}
4-
5
6
~I.
J