RosettaCodeData/Task/Strip-control-codes-and-extended-characters-from-a-string/Haskell/strip-control-codes-and-extended-characters-from-a-string.hs
2023-07-01 13:44:08 -04:00

12 lines
314 B
Haskell

import Control.Applicative (liftA2)
strip, strip2 :: String -> String
strip = filter (liftA2 (&&) (> 31) (< 126) . fromEnum)
-- or
strip2 = filter (((&&) <$> (> 31) <*> (< 126)) . fromEnum)
main :: IO ()
main =
(putStrLn . unlines) $
[strip, strip2] <*> ["alphabetic 字母 with some less parochial parts"]