Does someone know how to remove sinlge 1s from a bit mask using APLX? Example: 1 0 1 1 1 0 0 1 0 1 to 0 0 1 1 1 0 0 0 0 0
Hints greatly appreciated.
Does someone know how to remove sinlge 1s from a bit mask using APLX? Example: 1 0 1 1 1 0 0 1 0 1 to 0 0 1 1 1 0 0 0 0 0
Hints greatly appreciated.
This is one way:
b←1 0 1 1 1 0 0 1 0 1
1↓e∧(¯1⌽e)∨1⌽e←0,b
0 0 1 1 1 0 0 0 0 0
It gives an 1 if there is an 1 in the original vector, either followed or preceded by 1.
Here is one way. First, use the find function to locate all occurrances of 2 consecutive 1's, then use a shift and compare technique to extend all the runs of 1's by 1:
a←1 0 1 1 1 0 0 1 0 1
b←1 1⍷a
b
0 0 1 1 0 0 0 0 0 0
b∨0,¯1↓b
0 0 1 1 1 0 0 0 0 0