summaryrefslogtreecommitdiff
path: root/hw6/hw5.moon
blob: 568bf9db9766aa4947915790b44df35438a2934c (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
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