Count occurrences of a substring: Difference between revisions
m
→{{header|Quackery}}: tweaked commentary
(Added Quackery.) |
m (→{{header|Quackery}}: tweaked commentary) |
||
Line 2,525:
usefsm ] ] is find$ ( $ $ --> n )</lang>
<code>find$</code> builds a finite state machine to search for m, (an O(m³) operation), then uses it to search in n with O(n). Rather than use <code>find$</code>, and repeatedly build the same fsm, we will define a word <code>findall$</code> which returns a nest (i.e. list) of positions of m within n. (It actually returns the
<lang Quackery> [ over size 0 = iff
|