summaryrefslogtreecommitdiff
path: root/hw6/hw5.moon
diff options
context:
space:
mode:
authorAlexander Pickering <alex@cogarr.net>2020-01-01 22:37:37 -0500
committerAlexander Pickering <alex@cogarr.net>2020-01-01 22:37:37 -0500
commit9fae5d516012e2c0802105e67c79e2587a22b9dc (patch)
tree1c782ad2cd08bd1ecc4f0b42bd042778b4f34c2e /hw6/hw5.moon
downloadinfsci2620-9fae5d516012e2c0802105e67c79e2587a22b9dc.tar.gz
infsci2620-9fae5d516012e2c0802105e67c79e2587a22b9dc.tar.bz2
infsci2620-9fae5d516012e2c0802105e67c79e2587a22b9dc.zip
Inital commitHEADmaster
Diffstat (limited to 'hw6/hw5.moon')
-rw-r--r--hw6/hw5.moon24
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