How to resolve the algorithm Strip a set of characters from a string step by step in the Draco 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 Draco 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 Draco programming language
Source code in the draco programming language
\util.g
proc nonrec stripchars(*char str, chars, outbuf) *char:
channel input text ch_in;
channel output text ch_out;
[2]char cur = ('\e', '\e');
open(ch_in, str);
open(ch_out, outbuf);
while read(ch_in; cur[0]) do
if CharsIndex(chars, &cur[0]) = -1 then
write(ch_out; cur[0])
fi
od;
close(ch_in);
close(ch_out);
outbuf
corp
proc nonrec main() void:
[128]char buf;
writeln(
stripchars("She was a soul stripper. She took my heart!",
"aei", &buf[0]))
corp
You may also check:How to resolve the algorithm Hello world/Text step by step in the SETL programming language
You may also check:How to resolve the algorithm Largest int from concatenated ints step by step in the Maxima programming language
You may also check:How to resolve the algorithm Apply a digital filter (direct form II transposed) step by step in the Python programming language
You may also check:How to resolve the algorithm Count occurrences of a substring step by step in the Oforth programming language
You may also check:How to resolve the algorithm Vigenère cipher step by step in the PowerShell programming language