Jump to content

Count occurrences of a substring: Difference between revisions

→‎{{header|BQN}}: Scan-based solution
(→‎{{header|BQN}}: bqn-libs solution)
(→‎{{header|BQN}}: Scan-based solution)
Line 728:
 
=={{header|BQN}}==
<code>/𝕨⍷𝕩</code> finds locations of substrings, rest of the function removessuppresses theoverlapping substring for the next iterationsubstrings.
<lang bqn>Find←{b←𝕨⍷𝕩i←/𝕨⍷𝕩, (0≠+´b)◶⟨0i/˜i≥»0≤◶⟨⊣,1+𝕨𝕊·↓⟜𝕩(≠𝕨)+⟩⊑1↑/b⊢⟩`i}
 
•Show "abab" Find "ababababab"
99

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.