Strip control codes and extended characters from a string: Difference between revisions

→‎{{header|Nim}}: Added function for stripping control codes
(→‎{{header|Haskell}}: Added an equivalent variant, rewriting liftA2 as f <$> x <*> y, updating output)
(→‎{{header|Nim}}: Added function for stripping control codes)
Line 1,166:
 
=={{header|Nim}}==
<lang nim>proc stripped(str: string): string =
result = ""
for c in str:
Line 1,172:
result.add c
 
proc strippedControl(str: string): string =
result = ""
for c in str:
if ord(c) in {32..126, 128..255}:
result.add c
 
echo strippedControl "\ba\x00b\n\rc\fdÄ"
echo stripped "\ba\x00b\n\rc\fd\xc3"</lang>
Output:
<pre>abcd</pre>abcdÄ
abcd</pre>
 
=={{header|OCaml}}==