blob: 2da598f067424e9377c2ca5b4c3758b2209d26b0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
-- https://www.codewars.com/kata/52449b062fb80683ec000024
module Codewars.Kata.Hashtag where
import Data.Char
import Control.Monad
capitalized w = (toUpper $ head w) : (map toLower $ tail w)
processCapChar s =
join $ map (\x -> if isLower x then [x] else " "++[x]) s
generateHashtag :: String -> Maybe String
generateHashtag s = impl (processCapChar s)
where
impl s
| length (words s) == 0 = Nothing
| otherwise =
let result = "#" ++ (join $ map capitalized $ words s)
in
if (length result) > 140 then
Nothing
else
Just result
|