Count occurrences of a substring: Difference between revisions

Content added Content deleted
m (→‎{{header|Raku}}: Fix-up some Perl6 -> Raku references)
No edit summary
Line 1,309: Line 1,309:
1
1
</pre>
</pre>

== {{header|Lambdatalk}}==
<lang scheme>
{def countSubstring
{def countSubstring.r
{lambda {:n :i :acc :s}
{if {>= :i :n}
then :acc
else {countSubstring.r :n
{+ :i 1}
{if {W.equal? {W.get :i :s} ⫖}
then {+ :acc 1}
else :acc}
:s} }}}
{lambda {:w :s}
{countSubstring.r {W.length :s} 0 0
{S.replace \s by ⫕ in
{S.replace :w by ⫖ in :s}}}}}
-> countSubstring

{countSubstring th the three truths}
-> 3
{countSubstring ab ababa}
-> 2
{countSubstring aba ababa}
-> 1
</lang>


=={{header|Lasso}}==
=={{header|Lasso}}==