-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwordsTest.hs~
More file actions
25 lines (22 loc) · 851 Bytes
/
Copy pathwordsTest.hs~
File metadata and controls
25 lines (22 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import Control.Monad
import Data.Char
import Data.List
custWords :: String -> [String]
--custWords :: [Char] -> [[Char]]
custWords " " = []-- ["Nothinghere!"]
custWords [] = [] -- ["EmptyList!"]
custWords (' ':xs) = custWords xs
--custWords sentence = [firstW] ++ custWords restSentence
-- where (firstW, restSentence) = span (/=' ') sentence
custWords sentence
| restSentence == [] = [filter (`elem` (['a'..'z']++['A'..'Z']++['0','1'..'9']))firstW]
| otherwise = [filter (`elem` (['a'..'z']++['A'..'Z']++['0','1'..'9']))firstW] ++ custWords restSentence
where (firstW, restSentence) = span (/=' ') sentence
main = forever $ do
l <- getLine
-- HOW TO PRINT ints???
putStrLn $ "Length: " ++ (show $ length $ custWords l)
putStrLn $ intercalate "-" $ custWords l
--putStrLn toUpper l
--putStrLn l
--custWords l