From 9fae5d516012e2c0802105e67c79e2587a22b9dc Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Wed, 1 Jan 2020 22:37:37 -0500 Subject: Inital commit --- hw6/hw5.moon | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 hw6/hw5.moon (limited to 'hw6/hw5.moon') 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 -- cgit v1.2.3-70-g09d2