String matching: Difference between revisions

Content added Content deleted
(→‎{{header|Elixir}}: add Optional requirements)
Line 1,932: Line 1,932:
=={{header|Oforth}}==
=={{header|Oforth}}==


<lang Oforth>func: stringMatching(s1, s2)
<lang Oforth>: stringMatching(s1, s2)
{
| i |
| i |
s2 isAllAt(s1, 1) ifTrue: [ System.Out s1 << " begins with " << s2 << cr ]
s2 isAllAt(s1, 1) ifTrue: [ System.Out s1 << " begins with " << s2 << cr ]
Line 1,946: Line 1,945:
System.Out s1 << " includes " << s2 << " at position : " << i << cr
System.Out s1 << " includes " << s2 << " at position : " << i << cr
i s2 size + ->i
i s2 size + ->i
]
] ;</lang>
}</lang>


{{out}}
{{out}}
<pre>
<pre>
>stringMatching("arduinoardblobard", "ard")
> "arduinoardblobard", "ard" stringMatching
arduinoardblobard begins with ard
arduinoardblobard begins with ard
arduinoardblobard ends with ard
arduinoardblobard ends with ard