Strip a set of characters from a string: Difference between revisions

Adds slope example
m (syntax highlighting fixup automation)
(Adds slope example)
Line 2,451:
{{out}}
<pre>Sh ws soul strppr. Sh took my hrt!</pre>
 
=={{header|Slope}}==
 
This example ignores all type/error checking in favor of brevity and assumes
two strings will be given. A solution could also likely be crafted using '''regex-replace'''
or '''string-replace'''.
<syntaxhighlight lang="slope">(define strip-chars (lambda (str chrs)
(define chr-list (map (lambda (ch) (string->rune ch)) (string->list chrs)))
(list->string
(filter
(lambda (ch) (not (member? chr-list (string->rune ch))))
(string->list str)))))
 
(display (strip-chars "She was a soul stripper. She took my heart!" "aei"))</syntaxhighlight>
 
{{out}}
<pre>Sh ws soul strppr. Sh took my hrt!</pre>
 
=={{header|Smalltalk}}==
37

edits