Strip control codes and extended characters from a string: Difference between revisions
Strip control codes and extended characters from a string (view source)
Revision as of 19:34, 1 May 2019
, 5 years ago→{{header|Haskell}}: Added an equivalent variant, rewriting liftA2 as f <$> x <*> y, updating output
(→{{header|Haskell}}: Reduced the expression in terms of a liftA2 composition over two other functions.) |
(→{{header|Haskell}}: Added an equivalent variant, rewriting liftA2 as f <$> x <*> y, updating output) |
||
Line 878:
<lang Haskell>import Control.Applicative (liftA2)
strip, strip2 :: String -> String
strip = filter (liftA2 (&&) (> 31) (< 126) . fromEnum)
-- or
strip2 = filter (((&&) <$> (> 31) <*> (< 126)) . fromEnum)
main :: IO ()
main =
main = print $ strip "alphabetic 字母 with some less parochial parts"</lang>▼
(putStrLn . unlines) $
{{Out}}
<pre>
alphabetic with some less parochial parts</pre>
=={{header|Icon}} and {{header|Unicon}}==
|