diff options
Diffstat (limited to 'hw6/hw5.moon')
| -rw-r--r-- | hw6/hw5.moon | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/hw6/hw5.moon b/hw6/hw5.moon new file mode 100644 index 0000000..568bf9d --- /dev/null +++ b/hw6/hw5.moon @@ -0,0 +1,24 @@ + +accept_input = io.read + +split_string = (s) -> [x for x in string.gmatch(s,"(%S+)")] + +capitalize_word = (word) -> string.gsub(word,"^(.)",string.upper) + +uppercase_words = (array) -> + [capitalize_word(word) for word in *array] + +print_words = (array) -> + for word in *array do + print(word) + +sort_words = table.sort + +apply_caps = (str) -> + words = split_string(str) + words = uppercase_words(words) + sort_words(words) + words + +--return the apply_caps() function when we require() +apply_caps |
