How to resolve the algorithm Strip a set of characters from a string step by step in the Scala programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Strip a set of characters from a string step by step in the Scala programming language

Table of Contents

Problem Statement

Create a function that strips a set of characters from a string.

The function should take two arguments:

The returned string should contain the first string, stripped of any characters in the second argument:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Strip a set of characters from a string step by step in the Scala programming language

Source code in the scala programming language

def stripChars(s:String, ch:String)= s filterNot (ch contains _)

stripChars("She was a soul stripper. She took my heart!", "aei")
// => Sh ws  soul strppr. Sh took my hrt!


  

You may also check:How to resolve the algorithm Guess the number/With feedback step by step in the Tiny Craft Basic programming language
You may also check:How to resolve the algorithm Memory layout of a data structure step by step in the MATLAB / Octave programming language
You may also check:How to resolve the algorithm Execute a system command step by step in the K programming language
You may also check:How to resolve the algorithm Primality by trial division step by step in the J programming language
You may also check:How to resolve the algorithm Cheryl's birthday step by step in the Perl programming language