From 6a8e97190d55b1e0f94318e4e0316e50de7415c0 Mon Sep 17 00:00:00 2001 From: Abigail Date: Tue, 19 Jan 2021 13:43:39 +0100 Subject: lua solution for week 96, part 1 --- challenge-096/abigail/lua/ch-1.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 challenge-096/abigail/lua/ch-1.lua (limited to 'challenge-096/abigail/lua/ch-1.lua') diff --git a/challenge-096/abigail/lua/ch-1.lua b/challenge-096/abigail/lua/ch-1.lua new file mode 100644 index 0000000000..68d1c5eb86 --- /dev/null +++ b/challenge-096/abigail/lua/ch-1.lua @@ -0,0 +1,14 @@ +for line in io . lines () do + -- + -- Extract words and put them into an array, in reverse. + -- + words = {} + for str in string . gmatch (line, "[^ ]+") do + table . insert (words, 1, str) + end + + -- + -- Print the words + -- + io . write (table . concat (words, " "), "\n") +end -- cgit From b15a7dd19167fadcd7ef68d7807fb0915935fc5c Mon Sep 17 00:00:00 2001 From: Abigail Date: Tue, 19 Jan 2021 17:54:23 +0100 Subject: Make lua variables lexical --- challenge-096/abigail/lua/ch-1.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'challenge-096/abigail/lua/ch-1.lua') diff --git a/challenge-096/abigail/lua/ch-1.lua b/challenge-096/abigail/lua/ch-1.lua index 68d1c5eb86..9c4b1de913 100644 --- a/challenge-096/abigail/lua/ch-1.lua +++ b/challenge-096/abigail/lua/ch-1.lua @@ -2,7 +2,7 @@ for line in io . lines () do -- -- Extract words and put them into an array, in reverse. -- - words = {} + local words = {} for str in string . gmatch (line, "[^ ]+") do table . insert (words, 1, str) end -- cgit