118
Scan Operator 1\)
CD
The symbol for
the
scan
operator
is
\.
The forms
of
scan are:
(f)\[I]
B,G)\B
or
®~B,
where®can
be any scalar dyadic primitive function and argument B
is
a
numeric vector or other array. The scan operator, like
the
reduction operator,
operates on the elements
of
a single vector, and
is
the
same
as
putting
the
primitive
dyadic function between each of the elements. But
the
scan operator accumulates
the results
as
the
operation
is
repeated along the vector. The shape
of
the
result
is
the same
as
that
of
the
input argument:
+\:1. 2 3
1+
5
1.
3 6
:1.0
1.
5
......
~-----
This result
is
the same
as
doing
the
6
10
1
~5
1 following for each element
in
the
:1.+2
1.+2+~3
1.
+2+~5+1+
:1.
+2+~5+1.~+5
result. The first element
in
the
result
is
the first element
of
the
argument.
When argument B
is
a multidimensional array,
the
[I]
index entry
is
used
to
specify
the coordinate the scan
is
to
proceed along.
If
the
index entry
is
omitted, the last
coordinate (columns)
is
acted on.
If
the(f)
~B
form
is
'used,
the
first coordinate
is
acted on.
IH<5
,+p\l:~
B
.....
-----The
first coordinate (rows)
is
specified; therefore,
the scan
is
between rows .
.....
-----The
second coordinate (columns)
is
specified;
therefore,
the
scan
is
between columns.
/ "