Rep-string: Difference between revisions
m
→{{header|Haskell}}: Applied Hlint to first version.
m (→{{header|Haskell}}: Applied Hlint to first version.) |
|||
Line 1,331:
=={{header|Haskell}}==
<lang haskell>import Data.List (
import Data.Maybe (fromMaybe)
repstring :: String -> Maybe String
Line 1,337 ⟶ 1,338:
repstring [] = Nothing
-- strings with only one character are not rep strings
repstring
repstring xs
main :: IO ()
main =
[ "1001110011",
"0010010010",
process = maybe "Not a rep string" id . repstring▼
"0100101101",
putStrLn $ process xs</lang>▼
"0100100",
"101",
"11",
"00",
"1"
]
processIO xs = do
putStr (xs <> ": ")
{{Out}}
<pre>1001110011: 10011
|