Count occurrences of a substring: Difference between revisions
Content added Content deleted
(→{{header|Picat}}: Added subsections. Moved benchmark text after the code.) |
(add BQN) |
||
Line 726: | Line 726: | ||
"abab" in "ababababab": 2 |
"abab" in "ababababab": 2 |
||
"dog" in "cat": 0</pre> |
"dog" in "cat": 0</pre> |
||
=={{header|BQN}}== |
|||
<code>⍷</code> finds locations of substrings, rest of the function removes the substring for the next iteration. |
|||
<lang bqn>Find←{b←𝕨⍷𝕩, (0≠+´b)◶⟨0,1+𝕨𝕊·↓⟜𝕩(≠𝕨)⊸+⟩⊑1↑/b} |
|||
•Show "abab" Find "ababababab" |
|||
•Show "th" Find "the three truths"</lang> |
|||
<lang>2 |
|||
3</lang> |
|||
=={{header|Bracmat}}== |
=={{header|Bracmat}}== |