Topic: `APLX Help` : `Help on APL language` : `APL Primitives` : `\ Scan`
[ Previous | Next | Contents | Index | APL Home ]

`\` Scan

When used with a function operand, the `\` operator is known as 'scan'. The type of operation being carried out will be apparent from the context in which the symbol is used. Scan `(\)` can be applied to any dyadic function, including user- defined functions.

The left operand of `\` is any dyadic function. The effect is as if the function had been entered between all the elements of the data. In the absence of an axis specification, the function is applied to the last dimension. (This is similar to `/).` A given element of the result consists of the result of applying the function repeatedly over all the positions up to it. In each case the general rule for the order of execution is obeyed.

```             +\20 10 ¯5 7            (Compare with 20+10+¯5+7. The result shows
20 30 25 32                    the running totals and the final sum)
,\'AB' 'CD' 'EF'        (Repeated applications of ,)
AB ABCD ABCDEF
TABLE
5 2 3
4 7 6
×\ TABLE                (Puts × between all elements of TABLE
5 10  30                       and shows the result of each
4 28 168                       multiplication in row 1 and in row 2.
Note that since no dimension was
specified, the operation takes place
on the last dimension, the columns.
See [] - the axis operator)
```
```             ×⍀TABLE                 (First axis scan. Applies across each
5  2  3                       row, i.e. Down the columns. Same as
20 14 18                       ×\[1]TABLE)
```
```             ^\ 1 1 1 0 1 1          (Applies logical 'and' over all
1 1 1 0 0 0                    elements. A series of 1's is produced
up to the first 0. Shows where a test
first failed)
```
```             -\1 2 3 4               (The intermediate results are
1 ¯1 2 ¯2                      1
1 - 2
1 - 2 - 3
1 - 2 - 3 - 4
```

Useful examples of Scan include:

```             ^\                       All 0 after the first 0
∨\                       All 1 after the first 1
<\                       1 at the first 1
≤\                       0 at the first 0
≠\                       0 or 1, reversing at each 1
```

Topic: `APLX Help` : `Help on APL language` : `APL Primitives` : `\ Scan`
[ Previous | Next | Contents | Index | APL Home ]