feat: added two articles

This commit is contained in:
Nick 2024-12-17 02:17:06 -06:00
parent a751136971
commit 6cfdf6200e
166 changed files with 3507 additions and 237 deletions

View file

@ -26,3 +26,35 @@ wordCount text =
text
|> String.words
|> List.length
toTitleCase : String -> String
toTitleCase input =
let
lowercaseWords =
[ "a", "an", "the", "and", "but", "or", "for", "nor", "on", "at", "to", "in", "of", "with", "by" ]
words =
String.words input
capitalizeFirst word =
case String.uncons word of
Just ( first, rest ) ->
String.toUpper (String.fromChar first) ++ String.toLower rest
Nothing ->
""
capitalizeWord index word =
if index == 0 then
capitalizeFirst word
else if not (List.member (String.toLower word) lowercaseWords) then
capitalizeFirst word
else
String.toLower word
in
words
|> List.indexedMap capitalizeWord
|> String.join " "