Strip control codes and extended characters from a string: Difference between revisions
Content added Content deleted
(→{{header|OCaml}}: updated for recent ocaml versions with new type bytes) |
(→{{header|Haskell}}: Reduced the expression in terms of a liftA2 composition over two other functions.) |
||
Line 876: | Line 876: | ||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
<lang Haskell> |
<lang Haskell>import Control.Applicative (liftA2) |
||
strip = |
|||
strip :: String -> String |
|||
filter |
|||
strip = filter (liftA2 (&&) (> 31) (< 126) . fromEnum) |
|||
(\x -- Though use of Data.Char functions like isAlpha, isDigit etc |
|||
-- seems more probable. |
|||
-> |
|||
let o = fromEnum x |
|||
in o > 31 && o < 126) |
|||
main :: IO () |
main :: IO () |