Strip a set of characters from a string: Difference between revisions
Content added Content deleted
(→{{header|Picat}}: split into subsections) |
|||
Line 1,856: | Line 1,856: | ||
=={{header|Picat}}== |
=={{header|Picat}}== |
||
⚫ | |||
Two implementations: |
|||
⚫ | |||
* a function using list comprehension: stripchars/2 |
|||
* a predicate using recursion: stripchars2/2 |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
stripchars2(String, Chars, [], Res). |
stripchars2(String, Chars, [], Res). |
||
Line 1,880: | Line 1,869: | ||
stripchars2([H|T], Chars, Res1, [H|Res]) :- |
stripchars2([H|T], Chars, Res1, [H|Res]) :- |
||
stripchars2(T, Chars, Res1, Res).</lang> |
stripchars2(T, Chars, Res1, Res).</lang> |
||
===Test=== |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
{{out}} |
{{out}} |
||
<pre>Sh ws soul strppr. Sh took my hrt! |
<pre>Sh ws soul strppr. Sh took my hrt! |
||
Sh ws soul strppr. Sh took my hrt!</pre> |
Sh ws soul strppr. Sh took my hrt!</pre> |
||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |