Scan: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{Built-in|Scan|<nowiki>\</nowiki>}} is a monadic operator which takes a dyadic functions and produce a monadic function (<source lang=apl inline>\</source>). ==...") |
(No difference)
|
Revision as of 12:47, 9 September 2021
\
|
Scan (\
) is a monadic operator which takes a dyadic functions and produce a monadic function (\
).
Explanation
Scan is similar to Reduce, however all the intermediate results will be retained. That being said, unlike Reduce, Scan does not reduce the number of elements, i.e. performing Scan over a 10-elements array will produce a 10-elements array.
Examples
+\⍳5 ⍝ plus-scan over range of integer from 1 to 5 1 3 6 10 15
Applications
Removing disconnected trailing 1s from a boolean mask:
mask←1 1 1 1 0 1 1 0 0 1 mask 1 1 1 1 0 1 1 0 0 1 ∧\mask ⍝ and-scan mask 1 1 1 1 0 0 0 0 0 0